Skip to content

Commit 1a91afc

Browse files
Update code style
1 parent e8d1c43 commit 1a91afc

File tree

9 files changed

+29
-23
lines changed

9 files changed

+29
-23
lines changed

.editorconfig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ charset = utf-8
1515
trim_trailing_whitespace = true
1616
insert_final_newline = true
1717

18-
# Settings specific to Markdown files
19-
[*.md]
20-
trim_trailing_whitespace = false
18+
[*.hbs]
19+
insert_final_newline = false
20+
21+
[*.{diff,md}]
22+
trim_trailing_whitespace = false

.eslintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"semi": [2, "always"],
1616
"comma-style": [2, "last"],
1717
"one-var": [2, "never"],
18+
"strict": [2, "global"],
19+
"prefer-template": 2,
1820
"no-console": 0,
1921
"no-use-before-define": [2, "nofunc"],
2022
"no-underscore-dangle": 0,

config/config.node.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
'use strict';
2+
13
app.controller('SshDeployController', require('./controller'));

lib/bundler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
// A generic solution would be to use git-archive;
88
// See https://github.com/Strider-CD/strider-ssh-deploy/issues/2
99
bundleProject: function (dataDir, name, progress, done) {
10-
var bundlePath = '/tmp/' + name + '.tar.gz';
10+
var bundlePath = `/tmp/${name}.tar.gz`;
1111
var progstream = require('progress-stream');
1212
var progressEmitter = progstream({time: 1000});
1313
progressEmitter.on('progress', progress);
@@ -23,6 +23,6 @@ module.exports = {
2323
});
2424
},
2525
untarCmd: function (bundlePath, extractDir) {
26-
return 'tar -zxf ' + bundlePath + ' -C ' + extractDir + ' --strip-components=1';
26+
return `tar -zxf ${bundlePath} -C ${extractDir} --strip-components=1`;
2727
}
2828
};

lib/deploy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ module.exports = {
7474

7575
if (config.scp) {
7676
bundler.bundleProject(context.dataDir, projectName, function (tar) {
77-
context.comment('Compressing ... ' + Math.round(tar.percentage) + '%');
77+
context.comment(`Compressing ... ${Math.round(tar.percentage)}%`);
7878
}, function (err, bundlePath) {
7979
if (err) {
80-
return done(new Error('Could not create bundle ' + bundlePath));
80+
return done(new Error(`Could not create bundle ${bundlePath}`));
8181
} else {
8282
proceed({
8383
localBundlePath: bundlePath,
8484
progress: function (sftp) {
85-
context.comment('Uploading ... ' + Math.round(sftp.percentage) + '%');
85+
context.comment(`Uploading ... ${Math.round(sftp.percentage)}%`);
8686
}
8787
});
8888
}

lib/keys.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
whatIsMyPublicKey: function () {
1313
var pubKey = this.branch.pubkey;
1414
if (pubKey)
15-
return 'Your public key on this branch:\n' + pubKey;
15+
return `Your public key on this branch:\n${pubKey}`;
1616
else
1717
return 'You do not have a public key on this worker.';
1818
},
@@ -30,7 +30,7 @@ function findBranch(branches, name) {
3030
var foundBranch = false;
3131
branches.some(function (branch) {
3232
if (branch.name) {
33-
var regEx = new RegExp('^' + branch.name.replace(/\*/g, '.*') + '$');
33+
var regEx = new RegExp(`^${branch.name.replace(/\*/g, '.*')}$`);
3434
if (regEx.test(name)) {
3535
foundBranch = branch;
3636
return true;

lib/parse_host_string.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = function (str) {
3131
port = 22;
3232
}
3333
return {
34-
string: user+'@'+host+':'+port,
34+
string: `${user}@${host}:${port}`,
3535
user: user,
3636
host: host,
3737
port: port

lib/remote_paths.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'use strict';
22

33
module.exports = function (name) {
4-
var remote = '$HOME/' + name;
4+
var remote = `$HOME/${name}`;
55
var randomId = Math.random().toString(36).substring(7);
66

77
return {
88
name: name,
99
remote: remote,
10-
old: remote + '.old',
11-
bundle: '/tmp/package-' + randomId + '.tar.gz'
10+
old: `${remote}.old`,
11+
bundle: `/tmp/package-${randomId}.tar.gz`
1212
};
1313
};

lib/remotely.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ var progress = require('progress-stream');
77
var bundler = require('./bundler');
88

99
function devnull(str) {
10-
return str + ' > /dev/null 2>&1';
10+
return `${str} > /dev/null 2>&1`;
1111
}
1212

1313
function prepare(paths) {
1414
return [
15-
devnull('rm -rf ' + paths.old),
16-
devnull('mv ' + paths.remote + ' ' + paths.old),
17-
devnull('mkdir ' + paths.remote),
15+
devnull(`rm -rf ${paths.old}`),
16+
devnull(`mv ${paths.remote} ${paths.old}`),
17+
devnull(`mkdir ${paths.remote}`),
1818
devnull(bundler.untarCmd(paths.bundle, paths.remote)),
1919
'\n' // keep this newline so you can simply concat more onto this output
2020
].join('\n');
@@ -39,7 +39,7 @@ function runScript(conn, script, out, done) {
3939

4040
module.exports = {
4141
deploy: function (out, projectName, script, connectOptions, scp) {
42-
var prefix = 'Host ' + connectOptions.host + ':' + connectOptions.port + ' -- ';
42+
var prefix = `Host ${connectOptions.host}:${connectOptions.port} -- `;
4343
var paths = require('./remote_paths')(projectName);
4444
return new Promise(function (resolve, reject) {
4545
if (!connectOptions.username)
@@ -68,14 +68,14 @@ module.exports = {
6868
}
6969
}).on('error', function (err) {
7070
if (/Authentication failure/.test(err.message)) {
71-
reject(new Error(prefix + 'Public key is not authorized.\nCheck your key on the Branch tab.'));
71+
reject(new Error(`${prefix}Public key is not authorized.\nCheck your key on the Branch tab.`));
7272
} else
73-
reject(new Error(prefix + err.name + ': ' + err.message));
73+
reject(new Error(`${prefix}${err.name}: ${err.message}`));
7474
}).on('close', function (hadError) {
7575
if (hadError)
76-
reject(new Error(prefix + 'Remote connection had errors.')); // should have rejected already
76+
reject(new Error(`${prefix}Remote connection had errors.`)); // should have rejected already
7777
else if (exitCode !== 0)
78-
reject(new Error(prefix + 'Remote script exited non-zero ' + exitCode));
78+
reject(new Error(`${prefix}Remote script exited non-zero ${exitCode}`));
7979
else
8080
resolve();
8181
}).connect(connectOptions);

0 commit comments

Comments
 (0)