Skip to content
This repository was archived by the owner on Oct 28, 2020. It is now read-only.

Commit 9d49a3e

Browse files
author
TED Vortex (Teodor Eugen Dutulescu)
authored
Merge pull request #32 from superleap/gils31-bithound-local-checks
Gils31 bithound local checks
2 parents 05d84c3 + d159c16 commit 9d49a3e

File tree

4 files changed

+56
-32
lines changed

4 files changed

+56
-32
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
build/
33
node_modules/
44
lib/
5+
examples/

.eslintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
"accessor-pairs": 2,
2121
"array-callback-return": 2,
2222
"block-scoped-var": 2,
23-
"complexity": [1, 2],
23+
"complexity": [2, {"max": 3}],
2424
"consistent-return": 2,
2525
"curly": 2,
2626
"default-case": 2,
2727
"dot-location": [2, "property"],
28-
"dot-notation": [1, {"allowKeywords": false}],
28+
"dot-notation": 2,
2929
"eqeqeq": [2, "always"],
3030
"guard-for-in": 2,
3131
"no-alert": 2,

gulpfile.babel.js

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import Promise from 'bluebird';
22
import childProcess from 'child_process';
33
import conventionalChangelog from 'conventional-changelog';
4+
import del from 'del';
45
import fs from 'fs';
56
import gulp from 'gulp';
67
import gulpLoadPlugins from 'gulp-load-plugins';
8+
import mkdirp from 'mkdirp';
79
import path from 'path';
810
import readPackage from 'read-package-json';
911

10-
let exec = childProcess.exec;
1112
let pkg = Promise.promisify(readPackage);
1213
let readFile = Promise.promisify(fs.readFile);
14+
let spawn = childProcess.spawn;
1315
let writeFile = Promise.promisify(fs.writeFile);
1416

1517
const gp = gulpLoadPlugins();
@@ -23,29 +25,27 @@ const paths = {
2325
};
2426

2527
/**
26-
* Promisified child_process.exec
27-
* @param cmd
28-
* @param {Object} [opts={}] See child_process.exec node docs
29-
* @property {stream.Writable} [opts.stdout=process.stdout] - If defined, child process stdout will be piped to it.
30-
* @property {stream.Writable} [opts.stderr=process.stderr] - If defined, child process stderr will be piped to it.
31-
* @returns {Promise<{ stdout: string, stderr: stderr }>}
28+
* Promisified child_process.spawn
29+
* @async
30+
* @param {String} proc - The process we want to spawn
31+
* @param {Array} args - The arguments we want to spawn the process with
32+
* @param {Object} opts - See child_process.exec node docs
33+
* @param {String} [opts.stdio=`inherit`] - spawn environment inherits parent
34+
* @return {Promise<Error>}
3235
*/
33-
function execp(cmd, opts = {}) {
36+
function spawnp(proc, args = [], opts = { "stdio": `inherit` }) {
3437
return new Promise((resolve, reject) => {
35-
const child = exec(cmd, opts,
36-
(err, stdout, stderr) => {
37-
return err ? reject(err) : resolve({
38-
"stdout": stdout,
39-
"stderr": stderr
40-
});
41-
});
38+
const child = spawn(proc, args, opts);
39+
40+
child.on(`error`, (err) => {
41+
reject(err);
42+
});
4243

43-
if (opts.stdout) {
44-
child.stdout.pipe(opts.stdout);
45-
}
46-
if (opts.stderr) {
47-
child.stderr.pipe(opts.stderr);
48-
}
44+
child.on(`close`, (code) => {
45+
if (code === 0) {
46+
resolve();
47+
}
48+
});
4949
});
5050
}
5151

@@ -148,15 +148,15 @@ gulp.task(`nsp`, (cb) => {
148148
});
149149

150150
gulp.task(`snyk`, () => {
151-
return execp(`node_modules/.bin/snyk test`);
151+
return spawnp(`node_modules/.bin/snyk`, ["test", "--debug"]);
152152
});
153153

154154
gulp.task(`bithound`, () => {
155155
return pkg(paths.pkg, console.log, true).then((data) => {
156156
let pkgName = data.name;
157157
let pkgUser = data.repository.url.match(/github\.com\/([^\/]+)\//i)[1];
158158

159-
return execp(`node_modules/.bin/bithound check git@github.com:${pkgUser}/${pkgName}.git`);
159+
return spawnp(`node_modules/.bin/bithound`, [`check`, `git@github.com:${pkgUser}/${pkgName}.git`]);
160160
});
161161
});
162162

@@ -168,8 +168,29 @@ gulp.task(`package`, () => {
168168
});
169169
});
170170

171+
gulp.task(`clean:docs`, () => {
172+
return del([`${paths.docs}/*`]);
173+
});
174+
175+
gulp.task(`clean:manual`, () => {
176+
return del([`${paths.manual}/*`]);
177+
});
178+
179+
gulp.task(`setup`, [`clean`], () => {
180+
let log = [
181+
mkdirp(paths.docs),
182+
mkdirp(paths.manual)
183+
];
184+
185+
return Promise.all(log).then((response) => {
186+
return response;
187+
});
188+
});
189+
190+
gulp.task(`clean`, [`clean:docs`, `clean:manual`]);
171191
gulp.task(`test:install`, [`nsp`, `snyk`, `bithound`]);
172192
gulp.task(`test:publish`, [`test:install`, `package`]);
173193
gulp.task(`prepublish`, [`test:publish`]);
194+
gulp.task(`pretest`, [`setup`]);
174195
gulp.task(`test`, [`test:install`, `lint`]);
175196
gulp.task(`default`, [`test`]);

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,20 @@
3333
"homepage": "https://github.com/superleap/github-issues-label-sync#readme",
3434
"dependencies": {
3535
"bluebird": "^3.4.1",
36-
"github": "^2.1.0"
36+
"github": "^2.3.0"
3737
},
3838
"devDependencies": {
3939
"@semantic-release/last-release-npm": "https://github.com/vrtxf/last-release-npm/tarball/da5a0f2411e2add6f5b0b990b4a12fad3245cfac",
40-
"babel-core": "^6.10.4",
40+
"babel-core": "^6.11.4",
4141
"babel-plugin-add-module-exports": "^0.2.1",
4242
"babel-plugin-transform-es2015-block-scoping": "^6.10.1",
4343
"babel-preset-es2015": "^6.9.0",
44-
"babel-register": "^6.9.0",
45-
"bithound": "^1.6.0",
44+
"babel-register": "^6.11.6",
45+
"bithound": "https://github.com/vrtxf/cli.bithound.io/tarball/161a72d925c33876780bfebbfe2e4611cb99e7f0",
4646
"commitizen": "^2.8.2",
4747
"conventional-changelog": "^1.1.0",
4848
"cz-conventional-changelog": "^1.1.6",
49+
"del": "^2.2.1",
4950
"esdoc": "^0.4.7",
5051
"esdoc-hacker-vision": "^1.1.0",
5152
"esdoc-node": "^1.0.0",
@@ -60,13 +61,14 @@
6061
"gulp-istanbul": "^1.0.0",
6162
"gulp-load-plugins": "^1.2.4",
6263
"gulp-mocha": "^2.2.0",
63-
"gulp-nsp": "^2.4.1",
64+
"gulp-nsp": "^2.4.2",
6465
"gulp-plumber": "^1.1.0",
66+
"mkdirp": "^0.5.1",
6567
"mocha": "^2.5.3",
66-
"nsp": "^2.6.0",
68+
"nsp": "^2.6.1",
6769
"read-package-json": "^2.0.4",
6870
"semantic-release": "^6.3.0",
69-
"snyk": "^1.17.1"
71+
"snyk": "^1.17.4"
7072
},
7173
"config": {
7274
"commitizen": {

0 commit comments

Comments
 (0)