Skip to content

Commit

Permalink
Merge pull request #375 from quicksnap/example_build_tools
Browse files Browse the repository at this point in the history
Add script to help travis build all examples
  • Loading branch information
gaearon committed Jul 31, 2015
2 parents de301ce + 1879d00 commit 4358fc4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
language: node_js
node_js:
- "iojs"
script:
- npm test
- npm run build:examples

31 changes: 31 additions & 0 deletions examples/buildAll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Runs an ordered set of commands within each of the build directories.
*/

import fs from 'fs';
import path from 'path';
import { spawnSync } from 'child_process';

var exampleDirs = fs.readdirSync(__dirname).filter((file) => {
return fs.statSync(path.join(__dirname, file)).isDirectory();
});

// Ordering is important here. `npm install` must come first.
var cmdArgs = [
{ cmd: 'npm', args: ['install'] },
{ cmd: 'webpack', args: ['index.js'] }
];

for (let dir of exampleDirs) {
let opts = {
cwd: path.join(__dirname, dir),
stdio: 'inherit'
};

for (let cmdArg of cmdArgs) {
let result = spawnSync(cmdArg.cmd, cmdArg.args, opts);
if (result.status !== 0) {
throw new Error('Building examples exited with non-zero');
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"check": "npm run lint && npm run test",
"build:lib": "babel src --out-dir lib",
"build:umd": "webpack src/index.js dist/redux.js && NODE_ENV=production webpack src/index.js dist/redux.min.js",
"build:examples": "babel-node examples/buildAll.js",
"build": "npm run build:lib && npm run build:umd",
"preversion": "npm run clean && npm run check",
"version": "npm run build",
Expand Down

0 comments on commit 4358fc4

Please sign in to comment.