Run yarn as pre-commit hook if package.json was changed (#225)

This commit is contained in:
Artem Yavorsky 2017-03-24 17:35:26 +02:00 committed by Brian Ng
parent 03de20f043
commit b3bfd40195
2 changed files with 17 additions and 0 deletions

View File

@ -121,6 +121,10 @@
"test/*.js": [
"prettier --trailing-comma all --write",
"git add"
],
"package.json": [
"node ./scripts/yarn-install.js",
"git add yarn.lock"
]
}
}

View File

@ -0,0 +1,13 @@
"use strict";
const exec = require("child_process").exec;
const runIfYarn = fn => {
exec("yarn -V", error => {
if (error === null) fn();
});
};
runIfYarn(() => {
console.log("`package.json` was changed. Running yarn...🐈");
exec("yarn");
});