MXS-1300: Use single quotes in Node.js code

The Node.js code should use single quotes as it appears to be a prevalent
style choice for Node.js applications.
This commit is contained in:
Markus Mäkelä 2017-06-30 15:37:35 +03:00
parent 8fb1137ef0
commit 6955be901f
6 changed files with 20 additions and 20 deletions

View File

@ -39,10 +39,10 @@ module.exports = function() {
row = []
fields.forEach(function(p) {
var v = _.getPath(i, p[Object.keys(p)[0]], "")
var v = _.getPath(i, p[Object.keys(p)[0]], '')
if (Array.isArray(v)) {
v = v.join(", ")
v = v.join(', ')
}
row.push(v)
})
@ -63,10 +63,10 @@ module.exports = function() {
fields.forEach(function(i) {
var k = Object.keys(i)[0]
var path = i[k]
var v = _.getPath(res.data, path, "")
var v = _.getPath(res.data, path, '')
if (Array.isArray(v) && typeof(v[0]) != 'object') {
v = v.join(", ")
v = v.join(', ')
} else if (typeof(v) == 'object') {
v = JSON.stringify(v, null, 4)
}
@ -103,16 +103,16 @@ module.exports = function() {
request(args, function(err, resp, res) {
if (err) {
// Failed to request
console.log("Error:", JSON.stringify(err, null, 4))
console.log('Error:', JSON.stringify(err, null, 4))
} else if (resp.statusCode == 200 && cb) {
// Request OK, returns data
cb(res)
} else if (resp.statusCode == 204) {
// Request OK, no data
console.log(colors.green("OK"))
console.log(colors.green('OK'))
} else {
// Unexpected return code, probably an error
console.log("Error:", resp.statusCode, resp.statusMessage)
console.log('Error:', resp.statusCode, resp.statusMessage)
if (res) {
console.log(res)
}

View File

@ -18,12 +18,12 @@ exports.handler = function() {}
exports.builder = function(yargs) {
yargs
.command('server <server> <status>', 'Clear server status', {}, function(argv) {
var target = 'servers/' + argv.server + "/clear?status=" + argv.status
doRequest(target, null, {method: "POST"})
var target = 'servers/' + argv.server + '/clear?status=' + argv.status
doRequest(target, null, {method: 'POST'})
})
.usage("Usage: clear <command>")
.usage('Usage: clear <command>')
.help()
.command('*', 'the default command', {}, () => {
console.log("Unknown command. See output of 'help clear' for a list of commands.")
console.log('Unknown command. See output of `help clear` for a list of commands.')
})
}

View File

@ -65,9 +65,9 @@ exports.builder = function(yargs) {
{'Version': 'attributes.version'}
])
})
.usage("Usage: list <command>")
.usage('Usage: list <command>')
.help()
.command('*', 'the default command', {}, () => {
console.log("Unknown command. See output of 'help list' for a list of commands.")
console.log('Unknown command. See output of `help list` for a list of commands.')
})
}

View File

@ -18,12 +18,12 @@ exports.handler = function() {}
exports.builder = function(yargs) {
yargs
.command('server <server> <status>', 'Set server status', {}, function(argv) {
var target = 'servers/' + argv.server + "/set?status=" + argv.status
doRequest(target, null, {method: "POST"})
var target = 'servers/' + argv.server + '/set?status=' + argv.status
doRequest(target, null, {method: 'POST'})
})
.usage("Usage: set <command>")
.usage('Usage: set <command>')
.help()
.command('*', 'the default command', {}, () => {
console.log("Unknown command. See output of 'help set' for a list of commands.")
console.log('Unknown command. See output of `help set` for a list of commands.')
})
}

View File

@ -83,9 +83,9 @@ exports.builder = function(yargs) {
{'Commands': 'attributes.commands'}
])
})
.usage("Usage: show <command>")
.usage('Usage: show <command>')
.help()
.command('*', 'the default command', {}, () => {
console.log("Unknown command. See output of 'help show' for a list of commands.")
console.log('Unknown command. See output of `help show` for a list of commands.')
})
}

View File

@ -57,6 +57,6 @@ program
.help()
.demandCommand(1, 'At least one command is required')
.command('*', 'the default command', {}, () => {
console.log("Unknown command. See output of 'help' for a list of commands.")
console.log('Unknown command. See output of `help` for a list of commands.')
})
.argv