This repository has been archived by the owner on Apr 11, 2018. 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.
- Loading branch information
Showing
9 changed files
with
298 additions
and
311 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,8 @@ | ||
{ | ||
"extends": "airbnb/base", | ||
"rules": { | ||
"no-console": 0, | ||
"no-undef": 0, | ||
"arrow-body-style": 0 | ||
} | ||
} |
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,107 +1,105 @@ | ||
#!/usr/bin/env node | ||
var fs = require('fs'), | ||
colors = require('colors'), | ||
username = require('username'), | ||
autostart = require('./index.js'), | ||
argv = require('yargs') | ||
.usage('Usage: $0 <command> [options]') | ||
.command('enable', 'Enable autostart here with a custom key', function(yargs) { | ||
argv = yargs | ||
.option('n', { | ||
demand: true, | ||
alias: 'name', | ||
describe: 'Name of the key for identifying startup objects', | ||
type: 'string', | ||
nargs: 1 | ||
}) | ||
.option('c', { | ||
demand: false, | ||
alias: 'command', | ||
describe: 'Command to execute in the path', | ||
type: 'string', | ||
default: 'npm start' | ||
}) | ||
.option('p', { | ||
demand: false, | ||
alias: 'path', | ||
describe: 'Place of execution of command', | ||
type: 'string', | ||
default: process.cwd() | ||
}) | ||
.help('h') | ||
.alias('h', 'help') | ||
.showHelpOnFail(false, 'Use --help for further information') | ||
.argv; | ||
'use strict'; | ||
const autostart = require('./index.js'); | ||
let argv = require('yargs') | ||
.usage('Usage: $0 <command> [options]') | ||
.command('enable', 'Enable autostart here with a custom key', (yargs) => { | ||
argv = yargs | ||
.option('n', { | ||
demand: true, | ||
alias: 'name', | ||
describe: 'Name of the key for identifying startup objects', | ||
type: 'string', | ||
nargs: 1, | ||
}) | ||
.option('c', { | ||
demand: false, | ||
alias: 'command', | ||
describe: 'Command to execute in the path', | ||
type: 'string', | ||
default: 'npm start', | ||
}) | ||
.option('p', { | ||
demand: false, | ||
alias: 'path', | ||
describe: 'Place of execution of command', | ||
type: 'string', | ||
default: process.cwd(), | ||
}) | ||
.help('h') | ||
.alias('h', 'help') | ||
.showHelpOnFail(false, 'Use --help for further information') | ||
.argv; | ||
|
||
autostart.enableAutostart(argv.n, argv.c, argv.p, function(err) { | ||
if (err) { | ||
console.error('An error occured while trying to enable autostart, here are the details:'); | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
autostart.enableAutostart(argv.n, argv.c, argv.p, (err) => { | ||
if (err) { | ||
console.error('An error occured while trying to enable autostart, here are the details:'); | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
|
||
console.log('Done!'); | ||
process.exit(0); | ||
}); | ||
}) | ||
.command('disable', 'Disable autostart with key', function(yargs) { | ||
argv = yargs | ||
.option('n', { | ||
demand: true, | ||
alias: 'name', | ||
describe: 'Name of the key for identifying startup objecst', | ||
type: 'string', | ||
nargs: 1 | ||
}) | ||
.help('h') | ||
.alias('h', 'help') | ||
.showHelpOnFail(false, 'Use --help for further information') | ||
.argv; | ||
console.log('Done!'); | ||
process.exit(0); | ||
}); | ||
}) | ||
.command('disable', 'Disable autostart with key', (yargs) => { | ||
argv = yargs | ||
.option('n', { | ||
demand: true, | ||
alias: 'name', | ||
describe: 'Name of the key for identifying startup objecst', | ||
type: 'string', | ||
nargs: 1, | ||
}) | ||
.help('h') | ||
.alias('h', 'help') | ||
.showHelpOnFail(false, 'Use --help for further information') | ||
.argv; | ||
|
||
autostart.disableAutostart(argv.n, function(err) { | ||
if (err) { | ||
console.error('An error occured while trying to disable autostart, here are the details:'); | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
autostart.disableAutostart(argv.n, (err) => { | ||
if (err) { | ||
console.error('An error occured while trying to disable autostart, here are the details:'); | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
|
||
console.log('Done!'); | ||
process.exit(0); | ||
}); | ||
}) | ||
.command('check', 'Check if autostart is enabled by key', function(yargs) { | ||
argv = yargs | ||
.option('n', { | ||
demand: true, | ||
alias: 'name', | ||
describe: 'Name of the key for identifying startup objects', | ||
type: 'string', | ||
nargs: 1 | ||
}) | ||
.help('h') | ||
.alias('h', 'help') | ||
.showHelpOnFail(false, 'Use --help for further information') | ||
.argv; | ||
console.log('Done!'); | ||
process.exit(0); | ||
}); | ||
}) | ||
.command('check', 'Check if autostart is enabled by key', (yargs) => { | ||
argv = yargs | ||
.option('n', { | ||
demand: true, | ||
alias: 'name', | ||
describe: 'Name of the key for identifying startup objects', | ||
type: 'string', | ||
nargs: 1, | ||
}) | ||
.help('h') | ||
.alias('h', 'help') | ||
.showHelpOnFail(false, 'Use --help for further information') | ||
.argv; | ||
|
||
autostart.isAutostartEnabled(argv.n, function(err, isEnabled) { | ||
if (err) { | ||
console.error('An error occured while trying to check if autostart is enabled, here are the details:'); | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
autostart.isAutostartEnabled(argv.n, (err, isEnabled) => { | ||
if (err) { | ||
console.error('An error occured, here are the details:'); | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
|
||
console.log('Done!'); | ||
if (isEnabled) { | ||
console.log('Autostart is enabled'); | ||
process.exit(0); | ||
} else if (!isEnabled) { | ||
console.log('Autostart is not enabled'); | ||
process.exit(0); | ||
} | ||
}); | ||
}) | ||
.demand(1) | ||
.help('h') | ||
.alias('h', 'help') | ||
.showHelpOnFail(false, 'Use --help for further information') | ||
.argv; | ||
console.log('Done!'); | ||
if (isEnabled) { | ||
console.log('Autostart is enabled'); | ||
process.exit(0); | ||
} else if (!isEnabled) { | ||
console.log('Autostart is not enabled'); | ||
process.exit(0); | ||
} | ||
}); | ||
}) | ||
.demand(1) | ||
.help('h') | ||
.alias('h', 'help') | ||
.showHelpOnFail(false, 'Use --help for further information') | ||
.argv; |
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
Oops, something went wrong.