-
Notifications
You must be signed in to change notification settings - Fork 2
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
17 changed files
with
541 additions
and
333 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 @@ | ||
{ | ||
"presets": ["es2015", "react", "stage-0"], | ||
|
||
"plugins": [ | ||
"add-module-exports", | ||
"transform-decorators-legacy" | ||
] | ||
} |
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 @@ | ||
{"/Users/roy/royws/shell-executor/source/src/process.js":{"size":26,"mtime":1483338490000,"hashOfConfig":"suduii","results":{"filePath":"/Users/roy/royws/shell-executor/source/src/process.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/roy/royws/shell-executor/source/bin/cli.js":{"size":182,"mtime":1484751608000,"hashOfConfig":"suduii","results":{"filePath":"/Users/roy/royws/shell-executor/source/bin/cli.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/roy/royws/shell-executor/source/src/options.js":{"size":676,"mtime":1484751608000,"hashOfConfig":"suduii","results":{"filePath":"/Users/roy/royws/shell-executor/source/src/options.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/roy/royws/shell-executor/source/time-manager.js":{"size":390,"mtime":1484751608000,"hashOfConfig":"suduii","results":{"filePath":"/Users/roy/royws/shell-executor/source/time-manager.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/roy/royws/shell-executor/source/index.js":{"size":2879,"mtime":1484751986000,"hashOfConfig":"suduii","results":{"filePath":"/Users/roy/royws/shell-executor/source/index.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/roy/royws/shell-executor/source/src/main.js":{"size":3272,"mtime":1484752318000,"hashOfConfig":"suduii","results":{"filePath":"/Users/roy/royws/shell-executor/source/src/main.js","messages":[],"errorCount":0,"warningCount":0}},"/Users/roy/royws/shell-executor/specs/index.spec.js":{"size":1072,"mtime":1484752145000,"hashOfConfig":"suduii","results":{"filePath":"/Users/roy/royws/shell-executor/specs/index.spec.js","messages":[],"errorCount":0,"warningCount":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 |
---|---|---|
@@ -0,0 +1,177 @@ | ||
module.exports = { | ||
"parser": "babel-eslint", | ||
"plugins": [ | ||
"import", | ||
"mocha", | ||
"jsx-a11y", | ||
"react", | ||
], | ||
"extends": ["eslint:recommended", "airbnb"], | ||
"rules": { | ||
"mocha/no-exclusive-tests": 2, | ||
"eqeqeq": [2, "smart"], | ||
"curly": 2, | ||
"quotes": [2, "single", "avoid-escape"], | ||
"strict": 0, | ||
"no-unused-expressions": 0, | ||
"no-underscore-dangle": 0, | ||
"no-unused-vars": [2, { "vars": "all", "args": "after-used" }], | ||
"no-spaced-func" : 0, | ||
"jsx-a11y/anchor-has-content": 0, | ||
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }], | ||
"func-names": 2, | ||
"no-shadow": 2, | ||
"camelcase": 2, | ||
"new-cap": [2, {"capIsNewExceptions": ["Then", "When", "Given", "AfterFeatures", "After", "BeforeFeatures", "Before", "BeforeFeature"]}], | ||
"dot-notation": 2, | ||
"no-native-reassign": 1, | ||
"no-new": 1, | ||
"no-confusing-arrow": [2, {"allowParens": true}], | ||
"no-console": 0, | ||
"no-constant-condition": 1, | ||
"object-curly-spacing": 2, | ||
"consistent-return": 2, | ||
"jsx-quotes": 1, | ||
"newline-per-chained-call": 0, | ||
"no-unneeded-ternary": [2, {"defaultAssignment": true }], | ||
"no-extra-strict": 0, | ||
"no-alert": 2, | ||
"no-array-constructor": 2, | ||
"no-caller": 2, | ||
"no-catch-shadow": 2, | ||
"no-eval": 2, | ||
"no-extend-native": 2, | ||
"no-extra-bind": 2, | ||
"no-implied-eval": 2, | ||
"no-iterator": 2, | ||
"no-label-var": 2, | ||
"no-labels": 2, | ||
"no-lone-blocks": 2, | ||
"no-loop-func": 2, | ||
"no-multi-spaces": 0, | ||
"no-multi-str": 2, | ||
"no-new-func": 2, | ||
"no-new-object": 2, | ||
"no-new-wrappers": 2, | ||
"no-octal-escape": 2, | ||
"no-process-exit": 2, | ||
"no-proto": 2, | ||
"no-return-assign": 2, | ||
"no-script-url": 2, | ||
"no-sequences": 2, | ||
"no-undef": 2, | ||
"no-shadow-restricted-names": 2, | ||
"no-trailing-spaces": 2, | ||
"quote-props": 2, | ||
"object-shorthand": 2, | ||
"prefer-arrow-callback": 2, | ||
"template-curly-spacing": 0, | ||
"no-undef-init": 2, | ||
"id-length": 0, | ||
"no-use-before-define": 2, | ||
"no-with": 2, | ||
"comma-spacing": 2, | ||
"eol-last": 2, | ||
"padded-blocks": 0, | ||
"no-extra-parens": [2, "functions"], | ||
"key-spacing": [2, { "beforeColon": false, "afterColon": true }], | ||
"new-parens": 2, | ||
"semi": 2, | ||
"semi-spacing": [2, {"before": false, "after": true}], | ||
"space-infix-ops": 2, | ||
"keyword-spacing": 2, | ||
"space-unary-ops": [2, { "words": true, "nonwords": false }], | ||
"yoda": [2, "never"], | ||
"indent": 0, | ||
"vars-on-top": 0, | ||
"max-len": 0, | ||
"no-param-reassign": 0, | ||
"arrow-body-style": 2, | ||
"brace-style": 2, | ||
"prefer-template": 2, | ||
"computed-property-spacing": 1, | ||
"space-in-parens": 1, | ||
"no-useless-constructor": 2, | ||
"prefer-rest-params": 2, | ||
"array-bracket-spacing": 1, | ||
"no-case-declarations": 2, | ||
"array-callback-return": 2, | ||
"prefer-const": 2, | ||
"global-require": 2, | ||
"no-useless-escape": 2, | ||
"no-restricted-syntax": 2, | ||
"no-duplicate-imports": [2, { "includeExports": true }], | ||
"import/no-duplicates": [0, { "commonjs": true }], | ||
"import/no-unresolved": [0, { "commonjs": true }], | ||
"import/export": 1, | ||
"jsx-a11y/img-has-alt": 0, | ||
"react/jsx-equals-spacing": [1, "never"], | ||
"react/display-name": 0, | ||
"react/jsx-no-undef": 1, | ||
"react/jsx-no-bind": 2, | ||
"react/jsx-curly-spacing": [2, "always"], | ||
"react/jsx-first-prop-new-line": [2, "never"], | ||
"react/jsx-indent": [0, 2], | ||
"react/jsx-boolean-value": 0, | ||
"react/jsx-sort-prop-types": 0, | ||
"react/jsx-sort-props": 0, | ||
"react/jsx-uses-react": 1, | ||
"react/jsx-uses-vars": 1, | ||
"react/no-did-mount-set-state": 1, | ||
"react/no-did-update-set-state": 1, | ||
"react/jsx-closing-bracket-location": 0, | ||
"react/jsx-space-before-closing": 2, | ||
"react/no-multi-comp": 1, | ||
"react/no-unknown-property": 1, | ||
"react/prop-types": 0, | ||
"react/react-in-jsx-scope": 1, | ||
"react/self-closing-comp": 2, | ||
"react/sort-comp": 0, | ||
"react/wrap-multilines": 0, | ||
"react/jsx-indent-props": 0, | ||
"react/prefer-stateless-function": 1, | ||
"generator-star-spacing": 0, | ||
"import/no-extraneous-dependencies": 0, | ||
"linebreak-style": 2, | ||
"import/imports-first": 0, | ||
"react/no-string-refs": 0, | ||
"react/jsx-filename-extension": 0, | ||
"react/jsx-wrap-multilines": 0, | ||
"no-mixed-operators": 0, | ||
"import/prefer-default-export": 0, | ||
"import/newline-after-import": 0, | ||
"require-yield": 1, | ||
"no-extra-boolean-cast": 2, | ||
"no-continue": 2, | ||
"object-property-newline": 1, | ||
"no-prototype-builtins": 2, | ||
"operator-assignment": 2, | ||
"jsx-a11y/label-has-for": 2, | ||
"react/no-find-dom-node": 2, | ||
"no-lonely-if": 2, | ||
"dot-location": 2, | ||
"import/no-named-as-default": 1, | ||
"prefer-spread": 1 | ||
}, | ||
"env": { | ||
"browser": true, | ||
"node": true, | ||
"mocha": true, | ||
"es6": true | ||
}, | ||
"ecmaFeatures": { | ||
"jsx" : true, | ||
"modules": true | ||
}, | ||
"globals": { | ||
"__MOBX_DEVTOOLS__": true, | ||
"__DEVELOPMENT__": true, | ||
"__CLIENT__": true, | ||
"__SERVER__": true, | ||
"__DISABLE_SSR__": true, | ||
"__DEVTOOLS__": true, | ||
"socket": true, | ||
"jest": true, | ||
"expect": true, | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
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,115 +1 @@ | ||
var spawnly = require( 'spawnly' ); | ||
var extend = require( 'extend' ); | ||
var dispatchy = require( 'dispatchy' ); | ||
var Promise = require( 'es6-promise' ).Promise; | ||
|
||
var timeManager = require( './time-manager' ); | ||
|
||
function streamToString( stream ) { | ||
var chunks = [ ]; | ||
return new Promise( function ( resolve, reject ) { | ||
if ( !stream.readable ) { | ||
return resolve( '' ); | ||
} | ||
stream.on( 'data', function ( chunk ) { | ||
chunks.push( chunk.toString() ); | ||
} ); | ||
stream.on( 'end', function () { | ||
resolve( chunks.join( '' ) ); | ||
} ); | ||
stream.on( 'error', function ( err ) { | ||
reject( err ); | ||
} ); | ||
} ); | ||
} | ||
|
||
module.exports = { | ||
create: function () { | ||
var commands = [ ]; | ||
|
||
return extend( dispatchy.create(), { | ||
runCmds: function ( cmds, options ) { | ||
var me = this; | ||
cmds = cmds || [ ]; | ||
|
||
var promises = cmds.map( function ( cmd ) { | ||
return me.run( cmd, options ); | ||
} ); | ||
|
||
return Promise.all( promises ); | ||
}, | ||
run: function ( cmd, options ) { | ||
var me = this; | ||
|
||
var opts = extend( { stdio: 'inherit' }, options ); | ||
|
||
var timer = timeManager.start(); | ||
|
||
var cp = spawnly( cmd, opts ); | ||
|
||
me.fire( 'command:start', { cp: cp, cmd: cmd } ); | ||
|
||
cp.cmd = cmd; | ||
commands.push( cp ); | ||
|
||
return new Promise( function ( resolve, reject ) { | ||
cp.on( 'exit', function ( exitCode ) { | ||
var res = timer.stop(); | ||
|
||
var stdoutPromise = Promise.resolve( '' ); | ||
var stderrPromise = Promise.resolve( '' ); | ||
|
||
if ( cp.stdout ) { | ||
stdoutPromise = streamToString( cp.stdout ); | ||
} | ||
|
||
if ( cp.stderr ) { | ||
stderrPromise = streamToString( cp.stderr ); | ||
} | ||
|
||
Promise.all( [ stdoutPromise, stderrPromise ] ).then( function ( results ) { | ||
var args = { | ||
cp: cp, | ||
stdout: results[ 0 ], | ||
stderr: results[ 1 ], | ||
cmd: cmd, | ||
exitCode: exitCode, | ||
duration: res.diff, | ||
durationFormatted: res.diffFormatted | ||
}; | ||
me.fire( 'command:exit', args ); | ||
resolve( args ); | ||
} ); | ||
|
||
} ); | ||
|
||
cp.on( 'error', function ( err ) { | ||
err = err || { }; | ||
var res = timer.stop(); | ||
err.duration = res.diff; | ||
err.durationFormatted = res.diffFormatted; | ||
me.fire( 'command:error', err ); | ||
reject( err ); | ||
} ); | ||
} ); | ||
}, | ||
getKillCommand: function () { | ||
return 'kill -9 ' + commands.map( function ( cmd ) { | ||
return cmd.pid; | ||
} ).join( ' ' ); | ||
}, | ||
stopAll: function () { | ||
var me = this; | ||
commands.forEach( function ( cp ) { | ||
if ( !cp.exitCode ) { | ||
|
||
cp.removeAllListeners( 'exit' ); | ||
cp.removeAllListeners( 'error' ); | ||
me.fire( 'command:killed', cp ); | ||
cp.kill( 'SIGINT' ); | ||
} | ||
} ); | ||
} | ||
} ); | ||
} | ||
}; | ||
module.exports = require('./dist/index.js'); |
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.