Skip to content

Commit

Permalink
🚧 Update build method
Browse files Browse the repository at this point in the history
  • Loading branch information
VandeurenGlenn committed Feb 21, 2017
1 parent 75c48ab commit e4608e8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
src
19 changes: 9 additions & 10 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var del = require('del');
var merge = require('merge-stream');

let cache;
let cliCache;

task('static', () => {
return src('**/*.js')
Expand Down Expand Up @@ -71,18 +70,18 @@ task('coveralls', series('test', 'coveralls:after'));

task('rollup:run', () => {
return rollup.rollup({
entry: 'src/backed-cli.js',
entry: 'src/backed.js',
// Use the previous bundle as starting point.
cache: cliCache
cache: cache
}).then(bundle => {
var result = bundle.generate({
format: 'iife',
moduleName: 'backedCli',
moduleName: 'backed',
plugins: [json(), babel()]
});
// Cache our bundle for later use (optional)
cache = bundle;
fs.writeFileSync('.tmp/backed-cli.js', result.code);
fs.writeFileSync('.tmp/backed.js', result.code);
});
});

Expand All @@ -92,18 +91,18 @@ task('rollup:before', cb => {
});

task('rollup:after', () => {
var string = fs.readFileSync('.tmp/backed-cli.js').toString();
var string = fs.readFileSync('.tmp/backed.js').toString();
string = string.replace('(function', `#!/usr/bin/env node
(function`);
fs.unlinkSync('.tmp/backed-cli.js');
fs.writeFileSync('.tmp/backed-cli.js', string);
var cli = src('.tmp/backed-cli.js').pipe(dest('bin'));
fs.unlinkSync('.tmp/backed.js');
fs.writeFileSync('.tmp/backed.js', string);
var cli = src('.tmp/backed.js').pipe(dest('bin'));

return merge(cli);
});

task('clean', cb => {
del.sync(['.tmp/', 'bin/', 'lib/']);
del.sync(['.tmp/', 'bin/']);
cb();
});

Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{
"name": "backed-cli",
"version": "0.0.0",
"version": "0.0.0-alpha",
"description": "The official command line interface for Backed",
"homepage": "https://github.com/vandeurenglenn/backed-cli",
"author": {
"name": "Glenn Vandeuren",
"email": "[email protected]",
"url": ""
},
"preferGlobal": true,
"files": [
"lib",
"bin",
"src"
"bin"
],
"main": "lib/index.js",
"bin": {
"backed": "./bin/backed.js"
},
"keywords": [
""
],
Expand Down

0 comments on commit e4608e8

Please sign in to comment.