Add some pre-publish hooks to help prevent bad releases

This commit is contained in:
Francis Gulotta 2016-05-12 13:59:59 -04:00
parent 0063e13364
commit 3ede1e252e
3 changed files with 35 additions and 2 deletions

1
.gitignore vendored
View file

@ -7,3 +7,4 @@ npm-debug.log
gyp-mac-tool
.node_pre_gyprc
/.idea
.pre-publish-info

30
bin/pre-publish.js Executable file
View file

@ -0,0 +1,30 @@
#!/usr/bin/env node
'use strict';
var spawnSync = require('child_process').spawnSync;
var fs = require('fs');
var semver = require('semver');
// Log the packaging environment to be included in the npm bundle
var lsExit = spawnSync('npm', ['ls']).status;
var npmVersion = spawnSync('npm', ['-v']).stdout.toString().trim();
var info = {
'versions': process.versions,
'platform': process.platform,
'arch': process.arch,
'npm ls exit code': lsExit,
'npm version': npmVersion
};
fs.writeFileSync('.pre-publish-info', JSON.stringify(info, null, 2) + '\n');
if (lsExit !== 0) {
console.error('ls exited with a', lsExit);
process.exit(1);
}
// if (!semver.gt(npmVersion, '3.0.0') && !process.env.CI) {
// console.log('npm version must be above 3.0.0 <', npmVersion);
// process.exit(1);
// }

View file

@ -72,10 +72,11 @@
"mocha": "^2.4.5",
"node-pre-gyp-github": "^1.1.2",
"sandboxed-module": "^2.0.3",
"semver": "^5.1.0",
"sinon": "^1.17.3",
"sinon-chai": "^2.8.0"
},
"bundledDependencies":[
"bundledDependencies": [
"node-pre-gyp"
],
"engines": {
@ -92,7 +93,8 @@
"gyp-rebuild": "node-gyp rebuild",
"stress": "mocha --no-timeouts test/arduinoTest/stress.js",
"grunt": "grunt",
"test": "grunt --verbose"
"test": "grunt --verbose",
"prepublish": "node bin/pre-publish.js"
},
"gypfile": true
}