Skip to content
This repository was archived by the owner on Jun 17, 2018. It is now read-only.

add retirejs #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
npm-debug.log
gulpfile.js
.idea
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Opinionated builder for react web projects.
* `sd-builder lint` lints files with eslint
* `sd-builder test` runs tests
* `sd-builder coverage` runs tests and calculates coverage
* `sd-builder retire` checks dependencies vulnerabilities

## Main conventions

Expand Down
32 changes: 31 additions & 1 deletion gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {promisify} from "bluebird";
import browserSync from "browser-sync";
import {execSync} from "child_process";
import {execSync, spawn} from "child_process";
import history from "connect-history-api-fallback";
import dotenv from "dotenv";
import fs from "fs";
Expand All @@ -24,6 +24,7 @@ const testDir = `${process.cwd()}/test`;
const appDir = `${process.cwd()}/app`;
const buildDir = `${process.cwd()}/build`;
const depsPath = `${process.cwd()}/deps.json`;
const packagePath = `${process.cwd()}/package.json`;
const npmDir = `${process.cwd()}/node_modules/.bin`;


Expand Down Expand Up @@ -195,6 +196,29 @@ gulp.task("lint", () => {



/*
* Retire
*/

gulp.task("retire", function () {
// Spawn Retire.js as a child process
// You can optionally add option parameters to the second argument (array)
var child = spawn("retire", [], {cwd: process.cwd()});

child.stdout.setEncoding("utf8");
child.stdout.on("data", function (data) {
gp.util.log(data);
});

child.stderr.setEncoding("utf8");
child.stderr.on("data", function (data) {
gp.util.log(gp.util.colors.red(data));
gp.util.beep();
});
});

gulp.task("retire", proGulp.task("retire"));

/*
* Testers
*/
Expand Down Expand Up @@ -279,12 +303,17 @@ proGulp.task("setupWatchers", () => {
depsPath,
proGulp.parallel(["buildAllScripts", "buildVendorFonts", "buildVendorStyles", "test"])
);
gulp.watch(
[`${appDir}/**/*.js`, packagePath],
proGulp.task("retire")
);
});

gulp.task("dev", proGulp.sequence([
"build",
"config",
"test",
"retire",
"setupDevServer",
"setupWatchers"
]));
Expand All @@ -306,5 +335,6 @@ gulp.task("default", () => {
gp.util.log(" " + gp.util.colors.green("lint") + " lint application source code");
gp.util.log(" " + gp.util.colors.green("test") + " run tests");
gp.util.log(" " + gp.util.colors.green("coverage") + " run tests and calculate coverage");
gp.util.log(" " + gp.util.colors.green("retire") + " check dependencies vulnerabilities");
gp.util.log("");
});