Skip to content

Commit

Permalink
Generate the Chart.Deferred.js.zip package
Browse files Browse the repository at this point in the history
New `gulp package` task to ZIP dist files, samples and the license file. The archive is generated in the /dist folder and is deployed by Travis along the GH release. Note that the dist folder is not preserved but merged in the package root directory.
  • Loading branch information
simonbrunel committed Jun 15, 2016
1 parent d0dc6fe commit f428aeb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ node_js:
- '4.4'

script:
- gulp build
- gulp lint
- gulp build
- gulp package

deploy:
provider: releases
Expand All @@ -13,6 +14,7 @@ deploy:
file:
- "./dist/Chart.Deferred.js"
- "./dist/Chart.Deferred.min.js"
- "./dist/Chart.Deferred.js.zip"
skip_cleanup: true
on:
tags: true
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ Note that default options will defer the chart loading until the first line of p

## Development

The following commands are available from the repository root (requires [Node.js](https://nodejs.org/))
You first need to install node dependencies (requires [Node.js](https://nodejs.org/)):

```shell
> npm install
```

The following commands will then be available from the repository root:

```shell
> npm install // initialize node dependencies
> gulp build // build dist files
> gulp build --watch // build and watch for changes
> gulp lint // perform code linting
> gulp package // create an archive with dist files and samples
```

## License
Expand Down
25 changes: 24 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ var replace = require('gulp-replace');
var streamify = require('gulp-streamify');
var uglify = require('gulp-uglify');
var gutil = require('gulp-util');
var zip = require('gulp-zip');
var merge = require('merge2');
var path = require('path');
var package = require('./package.json');

var srcDir = './src/';
var outDir = './dist/';
var samplesDir = './samples/';

var header = "/*!\n\
* Chart.Deferred.js\n\
Expand All @@ -25,6 +28,7 @@ var header = "/*!\n\

gulp.task('build', buildTask);
gulp.task('lint', lintTask);
gulp.task('package', packageTask);
gulp.task('default', ['build']);

function watch(glob, task) {
Expand Down Expand Up @@ -57,9 +61,28 @@ function buildTask() {
}

function lintTask() {
var files = [srcDir + '**/*.js'];
var files = [
srcDir + '**/*.js',
samplesDir + '**/*.js'
];

return gulp.src(files)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}

function packageTask() {
return merge(
// gather "regular" files landing in the package root
gulp.src([outDir + '*.js', 'LICENSE.md']),

// dist files in the package are in the root, so we need to rewrite samples
// src="../dist/ to src="../ and then copy them in the /samples directory.
gulp.src(samplesDir + '**/*', { base: '.' })
.pipe(streamify(replace('src="../dist/', 'src="../')))
)
// finally, create the zip archive
.pipe(zip('Chart.Deferred.js.zip'))
.pipe(gulp.dest(outDir));
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"gulp-streamify": "^1.0.2",
"gulp-uglify": "^1.5.3",
"gulp-util": "^3.0.7",
"gulp-zip": "^3.2.0",
"merge2": "^1.0.2",
"path": "^0.12.7",
"yargs": "^4.7.1"
}
Expand Down

0 comments on commit f428aeb

Please sign in to comment.