Browse Source

make a binary of `now` using enclosejs (#81)

* make a binary of `now` using enclosejs

* pin enclosejs version
master
Igor Klopov 9 years ago
committed by Guillermo Rauch
parent
commit
67b55610b7
  1. 7
      bin/now
  2. 5
      enclose.js
  3. 9
      gulpfile.babel.js
  4. 4
      package.json

7
bin/now

@ -39,7 +39,12 @@ if (commands.has(cmd)) {
args = args.concat(process.argv.slice(2)); args = args.concat(process.argv.slice(2));
} }
const bin = resolve(__dirname, 'now-' + cmd); let bin = resolve(__dirname, 'now-' + cmd);
if (process.enclose) {
args.unshift("--entrypoint", bin);
bin = process.execPath;
}
const proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] }); const proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] });
proc.on('close', (code) => exit(code)); proc.on('close', (code) => exit(code));
proc.on('error', () => exit(1)); proc.on('error', () => exit(1));

5
enclose.js

@ -0,0 +1,5 @@
module.exports = {
scripts: [
"build/bin/now-*"
]
};

9
gulpfile.babel.js

@ -3,6 +3,7 @@ import del from 'del';
import babel from 'gulp-babel'; import babel from 'gulp-babel';
import uglify from 'gulp-uglify'; import uglify from 'gulp-uglify';
import help from 'gulp-task-listing'; import help from 'gulp-task-listing';
import { exec as enclose } from 'enclose';
gulp.task('help', help); gulp.task('help', help);
@ -23,6 +24,14 @@ gulp.task('compile-bin', () =>
.pipe(uglify()) .pipe(uglify())
.pipe(gulp.dest('build/bin'))); .pipe(gulp.dest('build/bin')));
gulp.task('enclose', ['compile'], (cb) => {
enclose([
'build/bin/now',
'-c', 'enclose.js',
'-o', 'build/now'
], cb);
});
gulp.task('watch-lib', () => gulp.watch('lib/*.js', ['compile-lib'])); gulp.task('watch-lib', () => gulp.watch('lib/*.js', ['compile-lib']));
gulp.task('watch-bin', () => gulp.watch('bin/*', ['compile-bin'])); gulp.task('watch-bin', () => gulp.watch('bin/*', ['compile-bin']));
gulp.task('clean', () => del(['build'])); gulp.task('clean', () => del(['build']));

4
package.json

@ -83,6 +83,7 @@
"babel-preset-es2015": "6.9.0", "babel-preset-es2015": "6.9.0",
"babel-register": "6.9.0", "babel-register": "6.9.0",
"del": "2.2.0", "del": "2.2.0",
"enclose": "2.1.0",
"eslint": "2.12.0", "eslint": "2.12.0",
"eslint-config-standard": "5.3.1", "eslint-config-standard": "5.3.1",
"eslint-plugin-promise": "1.3.2", "eslint-plugin-promise": "1.3.2",
@ -97,7 +98,8 @@
"scripts": { "scripts": {
"start": "gulp", "start": "gulp",
"test": "ava", "test": "ava",
"prepublish": "gulp compile" "prepublish": "gulp compile",
"enclose": "gulp enclose"
}, },
"ava": { "ava": {
"failFast": true, "failFast": true,

Loading…
Cancel
Save