update to modern code style (#1738)

* mv create-react-app/index.js -> create-react-app/creteReactApp.js

* update to modern code style

* var -> cosnt

* set trailing-coma to es5 for prettier
This commit is contained in:
Valerii Sorokobatko
2017-03-07 21:46:10 +02:00
committed by Dan Abramov
parent 43873dc9b8
commit fe7b5c212b
66 changed files with 2011 additions and 1637 deletions

View File

@@ -18,8 +18,8 @@ var execOptions = {
stdio: [
'pipe', // stdin (default)
'pipe', // stdout (default)
'ignore' //stderr
]
'ignore', //stderr
],
};
function isProcessAReactApp(processCommand) {
@@ -27,7 +27,10 @@ function isProcessAReactApp(processCommand) {
}
function getProcessIdOnPort(port) {
return execSync('lsof -i:' + port + ' -P -t -sTCP:LISTEN', execOptions).trim();
return execSync(
'lsof -i:' + port + ' -P -t -sTCP:LISTEN',
execOptions
).trim();
}
function getPackageNameInDirectory(directory) {
@@ -35,26 +38,30 @@ function getPackageNameInDirectory(directory) {
try {
return require(packagePath).name;
} catch(e) {
} catch (e) {
return null;
}
}
function getProcessCommand(processId, processDirectory) {
var command = execSync('ps -o command -p ' + processId + ' | sed -n 2p', execOptions);
var command = execSync(
'ps -o command -p ' + processId + ' | sed -n 2p',
execOptions
);
if (isProcessAReactApp(command)) {
const packageName = getPackageNameInDirectory(processDirectory);
return (packageName) ? packageName + '\n' : command;
return packageName ? packageName + '\n' : command;
} else {
return command;
}
}
function getDirectoryOfProcessById(processId) {
return execSync('lsof -p '+ processId + ' | awk \'$4=="cwd" {print $9}\'', execOptions).trim();
return execSync(
'lsof -p ' + processId + ' | awk \'$4=="cwd" {print $9}\'',
execOptions
).trim();
}
function getProcessForPort(port) {
@@ -63,10 +70,9 @@ function getProcessForPort(port) {
var directory = getDirectoryOfProcessById(processId);
var command = getProcessCommand(processId, directory);
return chalk.cyan(command) + chalk.blue(' in ') + chalk.cyan(directory);
} catch(e) {
} catch (e) {
return null;
}
}
module.exports = getProcessForPort;