Skip to content

Commit 436924e

Browse files
authored
Revert to default prettier config (#4)
1 parent bc915c7 commit 436924e

36 files changed

+1107
-1113
lines changed

Diff for: .eslintrc.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ module.exports = {
22
extends: ['standard', 'prettier'],
33
plugins: ['prettier'],
44
rules: {
5-
'prettier/prettier': [
6-
'error',
7-
{
8-
singleQuote: true,
9-
semi: false,
10-
},
11-
]
5+
'prettier/prettier': 'error'
126
},
137
env: { mocha: true }
148
}

Diff for: bin/uninstall.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
require('../lib/scripts/uninstall')()
1+
require("../lib/scripts/uninstall")();

Diff for: src/cli/bin.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env node
2-
const pkg = require('../../package.json')
3-
require('please-upgrade-node')(pkg)
2+
const pkg = require("../../package.json");
3+
require("please-upgrade-node")(pkg);
44

5-
const updateNotifier = require('update-notifier')
6-
const sudoBlock = require('sudo-block')
5+
const updateNotifier = require("update-notifier");
6+
const sudoBlock = require("sudo-block");
77

8-
sudoBlock('\nShould not be run as root, please retry without sudo.\n')
9-
updateNotifier({ pkg }).notify()
10-
require('./')(process.argv)
8+
sudoBlock("\nShould not be run as root, please retry without sudo.\n");
9+
updateNotifier({ pkg }).notify();
10+
require("./")(process.argv);

Diff for: src/cli/daemon.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
const fs = require('fs')
2-
const path = require('path')
3-
const mkdirp = require('mkdirp')
4-
const startup = require('user-startup')
5-
const common = require('../common')
6-
const conf = require('../conf')
7-
const uninstall = require('../scripts/uninstall')
1+
const fs = require("fs");
2+
const path = require("path");
3+
const mkdirp = require("mkdirp");
4+
const startup = require("user-startup");
5+
const common = require("../common");
6+
const conf = require("../conf");
7+
const uninstall = require("../scripts/uninstall");
88

99
module.exports = {
1010
start,
1111
stop
12-
}
12+
};
1313

1414
// Start daemon in background
1515
function start() {
16-
const node = process.execPath
17-
const daemonFile = path.join(__dirname, '../daemon')
18-
const startupFile = startup.getFile('chalet')
16+
const node = process.execPath;
17+
const daemonFile = path.join(__dirname, "../daemon");
18+
const startupFile = startup.getFile("chalet");
1919

20-
startup.create('chalet', node, [daemonFile], common.logFile)
20+
startup.create("chalet", node, [daemonFile], common.logFile);
2121

2222
// Save startup file path in ~/.chalet
2323
// Will be used later by uninstall script
24-
mkdirp.sync(common.chaletDir)
25-
fs.writeFileSync(common.startupFile, startupFile)
24+
mkdirp.sync(common.chaletDir);
25+
fs.writeFileSync(common.startupFile, startupFile);
2626

27-
console.log(`Started http://localhost:${conf.port}`)
27+
console.log(`Started http://localhost:${conf.port}`);
2828
}
2929

3030
// Stop daemon
3131
function stop() {
32-
startup.remove('chalet')
32+
startup.remove("chalet");
3333
// kills process and clean stuff in ~/.chalet
34-
uninstall()
35-
console.log('Stopped')
34+
uninstall();
35+
console.log("Stopped");
3636
}

Diff for: src/cli/index.js

+51-51
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,107 @@
1-
const yargs = require('yargs')
2-
const servers = require('./servers')
3-
const run = require('./run')
4-
const daemon = require('./daemon')
5-
const pkg = require('../../package.json')
1+
const yargs = require("yargs");
2+
const servers = require("./servers");
3+
const run = require("./run");
4+
const daemon = require("./daemon");
5+
const pkg = require("../../package.json");
66

77
const addOptions = {
88
name: {
9-
alias: 'n',
10-
describe: 'Server name'
9+
alias: "n",
10+
describe: "Server name"
1111
},
1212
port: {
13-
alias: 'p',
14-
describe: 'Set PORT environment variable',
13+
alias: "p",
14+
describe: "Set PORT environment variable",
1515
number: true
1616
},
1717
out: {
18-
alias: 'o',
19-
describe: 'Output file'
18+
alias: "o",
19+
describe: "Output file"
2020
},
2121
env: {
22-
alias: 'e',
23-
describe: 'Additional environment variables',
22+
alias: "e",
23+
describe: "Additional environment variables",
2424
array: true
2525
},
2626
xfwd: {
27-
alias: 'x',
28-
describe: 'Adds x-forward headers',
27+
alias: "x",
28+
describe: "Adds x-forward headers",
2929
default: false,
3030
boolean: true
3131
},
32-
'change-origin': {
33-
alias: 'co',
34-
describe: 'Changes the origin of the host header to the target URL',
32+
"change-origin": {
33+
alias: "co",
34+
describe: "Changes the origin of the host header to the target URL",
3535
default: false,
3636
boolean: true
3737
},
38-
'http-proxy-env': {
39-
describe: 'Adds HTTP_PROXY environment variable',
38+
"http-proxy-env": {
39+
describe: "Adds HTTP_PROXY environment variable",
4040
default: false,
4141
boolean: true
4242
},
4343
dir: {
44-
describe: 'Server directory',
44+
describe: "Server directory",
4545
string: true
4646
},
4747
force: {
48-
alias: 'f',
49-
describe: 'Forces creation of configuration if one already exits',
48+
alias: "f",
49+
describe: "Forces creation of configuration if one already exits",
5050
default: false,
5151
boolean: true
5252
}
53-
}
53+
};
5454

5555
module.exports = processArgv =>
5656
yargs(processArgv.slice(2))
5757
.version(pkg.version)
58-
.alias('v', 'version')
59-
.help('h')
60-
.alias('h', 'help')
58+
.alias("v", "version")
59+
.help("h")
60+
.alias("h", "help")
6161
.command(
62-
'add <cmd_or_url> [options]',
63-
'Add server or proxy',
62+
"add <cmd_or_url> [options]",
63+
"Add server or proxy",
6464
yargs => yargs.options(addOptions),
6565
// .demand(1),
6666
argv => servers.add(argv.cmd_or_url, argv)
6767
)
6868
.command(
69-
'run <cmd> [options]',
70-
'Run server and get a temporary local domain',
69+
"run <cmd> [options]",
70+
"Run server and get a temporary local domain",
7171
yargs => {
72-
const runOptions = { ...addOptions }
73-
delete runOptions.out
74-
return yargs.options(runOptions)
72+
const runOptions = { ...addOptions };
73+
delete runOptions.out;
74+
return yargs.options(runOptions);
7575
// TODO demand(1) ?
7676
},
7777
argv => run.spawn(argv.cmd, argv)
7878
)
7979
.command(
80-
'rm [options]',
81-
'Remove server or proxy',
80+
"rm [options]",
81+
"Remove server or proxy",
8282
yargs => {
83-
yargs.option('name', {
84-
alias: 'n',
85-
describe: 'Name'
86-
})
83+
yargs.option("name", {
84+
alias: "n",
85+
describe: "Name"
86+
});
8787
},
8888
argv => servers.rm(argv)
8989
)
90-
.command('ls', 'List servers', {}, argv => servers.ls(argv))
91-
.command('start', 'Start daemon', {}, () => daemon.start())
92-
.command('stop', 'Stop daemon', {}, () => daemon.stop())
93-
.example('$0 add --help')
94-
.example('$0 add nodemon')
95-
.example('$0 add npm start')
90+
.command("ls", "List servers", {}, argv => servers.ls(argv))
91+
.command("start", "Start daemon", {}, () => daemon.start())
92+
.command("stop", "Stop daemon", {}, () => daemon.stop())
93+
.example("$0 add --help")
94+
.example("$0 add nodemon")
95+
.example("$0 add npm start")
9696
.example("$0 add 'cmd -p $PORT'")
9797
.example("$0 add 'cmd -p $PORT' --port 4000")
9898
.example("$0 add 'cmd -p $PORT' --out app.log")
9999
.example("$0 add 'cmd -p $PORT' --name app")
100100
.example("$0 add 'cmd -p $PORT' --env PATH")
101-
.example('$0 add http://192.168.1.10 -n app ')
102-
.example('$0 rm')
103-
.example('$0 rm -n app')
104-
.epilog('https://github.com/jeansaad/chalet')
101+
.example("$0 add http://192.168.1.10 -n app ")
102+
.example("$0 rm")
103+
.example("$0 rm -n app")
104+
.epilog("https://github.com/jeansaad/chalet")
105105
.demand(1)
106106
.strict()
107-
.help().argv
107+
.help().argv;

Diff for: src/cli/run.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
const cp = require('child_process')
2-
const getPort = require('get-port')
3-
const servers = require('./servers')
4-
const getCmd = require('../get-cmd')
1+
const cp = require("child_process");
2+
const getPort = require("get-port");
3+
const servers = require("./servers");
4+
const getCmd = require("../get-cmd");
55

6-
const signals = ['SIGINT', 'SIGTERM', 'SIGHUP']
6+
const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
77

88
module.exports = {
99
// For testing purpose, allows stubbing cp.spawnSync
1010
_spawnSync(...args) {
11-
cp.spawnSync(...args)
11+
cp.spawnSync(...args);
1212
},
1313

1414
// For testing purpose, allows stubbing process.exit
1515
_exit(...args) {
16-
process.exit(...args)
16+
process.exit(...args);
1717
},
1818

1919
spawn(cmd, opts = {}) {
2020
const cleanAndExit = (code = 0) => {
21-
servers.rm(opts)
22-
this._exit(code)
23-
}
21+
servers.rm(opts);
22+
this._exit(code);
23+
};
2424

2525
const startServer = port => {
26-
const serverAddress = `http://localhost:${port}`
26+
const serverAddress = `http://localhost:${port}`;
2727

28-
process.env.PORT = port
29-
servers.add(serverAddress, opts)
28+
process.env.PORT = port;
29+
servers.add(serverAddress, opts);
3030

31-
signals.forEach(signal => process.on(signal, cleanAndExit))
31+
signals.forEach(signal => process.on(signal, cleanAndExit));
3232

33-
const [command, ...args] = getCmd(cmd)
33+
const [command, ...args] = getCmd(cmd);
3434
const { status, error } = this._spawnSync(command, args, {
35-
stdio: 'inherit',
35+
stdio: "inherit",
3636
cwd: process.cwd()
37-
})
37+
});
3838

39-
if (error) throw error
40-
cleanAndExit(status)
41-
}
39+
if (error) throw error;
40+
cleanAndExit(status);
41+
};
4242

4343
if (opts.port) {
44-
startServer(opts.port)
44+
startServer(opts.port);
4545
} else {
4646
getPort()
4747
.then(startServer)
4848
.catch(err => {
49-
throw err
50-
})
49+
throw err;
50+
});
5151
}
5252
}
53-
}
53+
};

0 commit comments

Comments
 (0)