Skip to content

Commit 44e367d

Browse files
committed
Initial commit
0 parents  commit 44e367d

11 files changed

+212
-0
lines changed

.babelrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["es2015"],
3+
"plugins": []
4+
}

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = crlf
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Tt]humbs.db
2+
.DS_Store
3+
npm-debug.log
4+
5+
/node_modules/
6+
/lib/
7+
/coverage/

.travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
matrix:
3+
include:
4+
- node_js: '0.12'
5+
- node_js: iojs
6+
- node_js: 4
7+
- node_js: 5
8+
env: COVERALLS=1
9+
after_success:
10+
- '[[ "$COVERALLS" ]] && gulp coveralls'

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Copyright (c) 2016 Zentrick nv
2+
3+
Permission is hereby granted, free of charge, to any person
4+
obtaining a copy of this software and associated documentation
5+
files (the "Software"), to deal in the Software without
6+
restriction, including without limitation the rights to use,
7+
copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the
9+
Software is furnished to do so, subject to the following
10+
conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# cross-spawn-promise
2+
3+
[![npm](https://img.shields.io/npm/v/cross-spawn-promise.svg)](https://www.npmjs.com/package/cross-spawn-promise) [![Dependencies](https://img.shields.io/david/zentrick/cross-spawn-promise.svg)](https://david-dm.org/zentrick/cross-spawn-promise) [![Build Status](https://img.shields.io/travis/zentrick/cross-spawn-promise.svg)](https://travis-ci.org/zentrick/cross-spawn-promise) [![Coverage Status](https://img.shields.io/coveralls/zentrick/cross-spawn-promise.svg)](https://coveralls.io/r/zentrick/cross-spawn-promise) [![JavaScript Standard Style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)
4+
5+
Promisified [cross-spawn-async](https://www.npmjs.com/package/cross-spawn-async).
6+
7+
## Maintainer
8+
9+
- [Tim De Pauw](https://github.com/timdp)
10+
11+
## License
12+
13+
MIT

gulpfile.babel.js

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import gulp from 'gulp'
2+
import loadPlugins from 'gulp-load-plugins'
3+
import {Instrumenter} from 'isparta'
4+
import del from 'del'
5+
import mkdirp from 'mkdirp'
6+
import seq from 'run-sequence'
7+
8+
const DEST = 'lib'
9+
10+
const $ = loadPlugins()
11+
12+
const plumb = () => $.plumber({
13+
errorHandler: $.notify.onError('<%= error.message %>')
14+
})
15+
16+
const test = () => {
17+
return gulp.src(['test/lib/setup.js', 'test/unit/**/*.js'], {read: false})
18+
.pipe(plumb())
19+
.pipe($.mocha({reporter: 'dot'}))
20+
}
21+
22+
gulp.task('clean', () => del.sync(DEST))
23+
24+
gulp.task('transpile', () => {
25+
mkdirp.sync(DEST)
26+
return gulp.src('src/**/*.js')
27+
.pipe(plumb())
28+
.pipe($.sourcemaps.init())
29+
.pipe($.babel())
30+
.pipe($.sourcemaps.write())
31+
.pipe(gulp.dest(DEST))
32+
})
33+
34+
gulp.task('lint', () => {
35+
return gulp.src('src/**/*.js')
36+
.pipe(plumb())
37+
.pipe($.standard())
38+
.pipe($.standard.reporter('default', {
39+
breakOnError: false
40+
}))
41+
})
42+
43+
gulp.task('build', (cb) => seq('lint', 'test', 'transpile', cb))
44+
45+
gulp.task('cleanbuild', (cb) => seq('clean', 'build', cb))
46+
47+
gulp.task('coverage', (cb) => {
48+
gulp.src('src/**/*.js')
49+
.pipe(plumb())
50+
.pipe($.istanbul({instrumenter: Instrumenter}))
51+
.pipe($.istanbul.hookRequire())
52+
.on('finish', () => test().pipe($.istanbul.writeReports()).on('end', cb))
53+
})
54+
55+
gulp.task('coveralls', ['coverage'], () => {
56+
return gulp.src('coverage/lcov.info')
57+
.pipe(plumb())
58+
.pipe($.coveralls())
59+
})
60+
61+
gulp.task('test', test)
62+
63+
gulp.task('watch', () => gulp.watch('{src,test}/**/*', ['cleanbuild']))
64+
65+
gulp.task('default', ['cleanbuild'], () => gulp.start('watch'))

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./lib/').default

package.json

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "cross-spawn-promise",
3+
"version": "0.0.0",
4+
"description": "Promisified cross-spawn-async.",
5+
"main": "index.js",
6+
"author": "Zentrick nv (https://www.zentrick.com/)",
7+
"contributors": [
8+
"Tim De Pauw <[email protected]>"
9+
],
10+
"engines": {
11+
"node": ">=0.12.0"
12+
},
13+
"license": "MIT",
14+
"files": [
15+
"lib/",
16+
"index.js"
17+
],
18+
"scripts": {
19+
"clean": "gulp clean",
20+
"build": "gulp build",
21+
"prepublish": "npm run clean && npm run build",
22+
"test": "gulp test"
23+
},
24+
"repository": "zentrick/cross-spawn-promise",
25+
"bugs": {
26+
"url": "https://github.com/zentrick/cross-spawn-promise/issues"
27+
},
28+
"dependencies": {
29+
"cross-spawn-async": "^2.1.9"
30+
},
31+
"devDependencies": {
32+
"babel-eslint": "^5.0.0",
33+
"babel-preset-es2015": "^6.5.0",
34+
"babel-register": "^6.5.2",
35+
"chai": "^3.5.0",
36+
"chai-as-promised": "^5.2.0",
37+
"del": "^2.2.0",
38+
"gulp": "^3.9.1",
39+
"gulp-babel": "^6.1.2",
40+
"gulp-coveralls": "^0.1.4",
41+
"gulp-istanbul": "^0.10.3",
42+
"gulp-load-plugins": "^1.2.0",
43+
"gulp-mocha": "^2.2.0",
44+
"gulp-notify": "^2.2.0",
45+
"gulp-plumber": "^1.1.0",
46+
"gulp-sourcemaps": "^1.6.0",
47+
"gulp-standard": "^6.0.5",
48+
"isparta": "^4.0.0",
49+
"mkdirp": "^0.5.1",
50+
"run-sequence": "^1.1.5"
51+
},
52+
"standard": {
53+
"parser": "babel-eslint"
54+
}
55+
}

src/index.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict'
2+
3+
import crossSpawn from 'cross-spawn-async'
4+
5+
export default (cmd, args, opt) => new Promise((resolve, reject) => {
6+
const proc = crossSpawn(cmd, args, opt)
7+
let stdout = ''
8+
let stderr = ''
9+
proc.stdout.on('data', (data) => { stdout += data.toString() })
10+
proc.stderr.on('data', (data) => { stderr += data.toString() })
11+
proc.once('close', (code) => {
12+
if (code !== 0) {
13+
const err = new Error(`Exited with status ${code}`)
14+
err.stderr = stderr
15+
reject(err)
16+
} else {
17+
resolve(stdout)
18+
}
19+
})
20+
})

test/lib/setup.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import chai from 'chai'
2+
import chaiAsPromised from 'chai-as-promised'
3+
4+
chai.use(chaiAsPromised)
5+
6+
global.expect = chai.expect

0 commit comments

Comments
 (0)