This repository has been archived by the owner on Nov 29, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to standard/prettier formatting
- Loading branch information
1 parent
eae75a0
commit a3543e7
Showing
12 changed files
with
444 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
'extends': [ | ||
'standard', | ||
'prettier', | ||
], | ||
'plugins': [ | ||
'standard', | ||
'promise', | ||
'prettier' | ||
], | ||
rules: { | ||
'standard/no-callback-literal': 0, | ||
'prettier/prettier': ['error', { | ||
printWidth: 80, | ||
tabWidth: 2, | ||
singleQuote: true, | ||
trailingComma: 'es5', | ||
bracketSpacing: true, | ||
semi: false, | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
'use strict' | ||
|
||
require('./prettier_d'); | ||
require('./prettier_d') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,54 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
'use strict' | ||
|
||
function start() { | ||
require('../lib/launcher')(); | ||
require('../lib/launcher')() | ||
} | ||
|
||
var cmd = process.argv[2]; | ||
var cmd = process.argv[2] | ||
if (cmd === 'start') { | ||
|
||
start(); | ||
|
||
start() | ||
} else if (cmd === '-v' || cmd === '--version') { | ||
|
||
console.log('v%s (prettier_d v%s)', | ||
console.log( | ||
'v%s (prettier_d v%s)', | ||
require('prettier/package.json').version, | ||
require('../package.json').version); | ||
|
||
require('../package.json').version | ||
) | ||
} else if (cmd === '-h' || cmd === '--help') { | ||
|
||
var options = require('../lib/options'); | ||
console.log(options.generateHelp()); | ||
|
||
var options = require('../lib/options') | ||
console.log(options.generateHelp()) | ||
} else { | ||
|
||
var client = require('../lib/client'); | ||
var client = require('../lib/client') | ||
if (cmd === 'restart') { | ||
client.stop(function () { | ||
process.nextTick(start); | ||
}); | ||
client.stop(function() { | ||
process.nextTick(start) | ||
}) | ||
} else { | ||
var commands = ['stop', 'status', 'restart']; | ||
var commands = ['stop', 'status', 'restart'] | ||
if (commands.indexOf(cmd) === -1) { | ||
var useStdIn = (process.argv.indexOf('--stdin') > -1); | ||
var args = process.argv.slice(2); | ||
var useStdIn = process.argv.indexOf('--stdin') > -1 | ||
var args = process.argv.slice(2) | ||
|
||
if (!require('supports-color')) { | ||
args.unshift('--no-color'); | ||
args.unshift('--no-color') | ||
} | ||
|
||
if (useStdIn) { | ||
var text = ''; | ||
process.stdin.setEncoding('utf8'); | ||
var text = '' | ||
process.stdin.setEncoding('utf8') | ||
|
||
process.stdin.on('data', function (chunk) { | ||
text += chunk; | ||
}); | ||
process.stdin.on('data', function(chunk) { | ||
text += chunk | ||
}) | ||
|
||
process.stdin.on('end', function () { | ||
client.lint(args, text); | ||
}); | ||
process.stdin.on('end', function() { | ||
client.lint(args, text) | ||
}) | ||
} else { | ||
client.lint(args); | ||
client.lint(args) | ||
} | ||
} else { | ||
client[cmd](process.argv.slice(3)); | ||
client[cmd](process.argv.slice(3)) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,96 @@ | ||
'use strict'; | ||
'use strict' | ||
|
||
var net = require('net'); | ||
var portfile = require('./portfile'); | ||
var net = require('net') | ||
var portfile = require('./portfile') | ||
|
||
function connect(callback) { | ||
var data = portfile.read(); | ||
var data = portfile.read() | ||
if (data) { | ||
var socket = net.connect(data.port, function () { | ||
callback(null, socket, data.token); | ||
}); | ||
socket.on('error', function () { | ||
callback('Could not connect'); | ||
}); | ||
var socket = net.connect(data.port, function() { | ||
callback(null, socket, data.token) | ||
}) | ||
socket.on('error', function() { | ||
callback('Could not connect') | ||
}) | ||
} else { | ||
callback('Not running'); | ||
callback('Not running') | ||
} | ||
} | ||
|
||
exports.stop = function (callback) { | ||
connect(function (err, socket, token) { | ||
exports.stop = function(callback) { | ||
connect(function(err, socket, token) { | ||
if (err) { | ||
process.stdout.write(err + '\n'); | ||
return; | ||
process.stdout.write(err + '\n') | ||
return | ||
} | ||
socket.end(token + ' stop', function () { | ||
socket.end(token + ' stop', function() { | ||
if (typeof callback === 'function') { | ||
callback(); | ||
callback() | ||
} | ||
}); | ||
}); | ||
}; | ||
}) | ||
}) | ||
} | ||
|
||
exports.status = function () { | ||
connect(function (err, socket) { | ||
exports.status = function() { | ||
connect(function(err, socket) { | ||
if (err) { | ||
process.stdout.write(err + '\n'); | ||
return; | ||
process.stdout.write(err + '\n') | ||
return | ||
} | ||
socket.end(function () { | ||
process.stdout.write('Running\n'); | ||
}); | ||
}); | ||
}; | ||
socket.end(function() { | ||
process.stdout.write('Running\n') | ||
}) | ||
}) | ||
} | ||
|
||
exports.lint = function (args, text) { | ||
exports.lint = function(args, text) { | ||
if (!args.length && !text) { | ||
process.stdout.write('No files specified\n'); | ||
return; | ||
process.stdout.write('No files specified\n') | ||
return | ||
} | ||
|
||
function lint(socket, token) { | ||
var buf = ''; | ||
socket.on('data', function (chunk) { | ||
buf += chunk; | ||
var p = buf.lastIndexOf('\n'); | ||
var buf = '' | ||
socket.on('data', function(chunk) { | ||
buf += chunk | ||
var p = buf.lastIndexOf('\n') | ||
if (p !== -1) { | ||
process.stdout.write(buf.substring(0, p + 1)); | ||
buf = buf.substring(p + 1); | ||
process.stdout.write(buf.substring(0, p + 1)) | ||
buf = buf.substring(p + 1) | ||
} | ||
}); | ||
socket.on('end', function () { | ||
}) | ||
socket.on('end', function() { | ||
if (buf) { | ||
if (buf === '# exit 1') { | ||
process.exitCode = 1; | ||
process.exitCode = 1 | ||
} else { | ||
process.stdout.write(buf); | ||
process.stdout.write(buf) | ||
} | ||
} | ||
}); | ||
socket.end(token + ' ' + JSON.stringify({ | ||
cwd: process.cwd(), | ||
args: args, | ||
text: text | ||
})); | ||
}) | ||
socket.end( | ||
token + | ||
' ' + | ||
JSON.stringify({ | ||
cwd: process.cwd(), | ||
args: args, | ||
text: text, | ||
}) | ||
) | ||
} | ||
connect(function (err, socket, token) { | ||
connect(function(err, socket, token) { | ||
if (err) { | ||
require('./launcher')(function () { | ||
connect(function (err, socket, token) { | ||
require('./launcher')(function() { | ||
connect(function(err, socket, token) { | ||
if (err) { | ||
process.stdout.write(err + '\n'); | ||
process.stdout.write(err + '\n') | ||
} else { | ||
lint(socket, token); | ||
lint(socket, token) | ||
} | ||
}); | ||
}); | ||
}) | ||
}) | ||
} else { | ||
lint(socket, token); | ||
lint(socket, token) | ||
} | ||
}); | ||
}; | ||
}) | ||
} |
Oops, something went wrong.