Skip to content

Commit 4358fc4

Browse files
committed
Merge pull request reduxjs#375 from quicksnap/example_build_tools
Add script to help travis build all examples
2 parents de301ce + 1879d00 commit 4358fc4

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
language: node_js
22
node_js:
33
- "iojs"
4+
script:
5+
- npm test
6+
- npm run build:examples
7+

examples/buildAll.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Runs an ordered set of commands within each of the build directories.
3+
*/
4+
5+
import fs from 'fs';
6+
import path from 'path';
7+
import { spawnSync } from 'child_process';
8+
9+
var exampleDirs = fs.readdirSync(__dirname).filter((file) => {
10+
return fs.statSync(path.join(__dirname, file)).isDirectory();
11+
});
12+
13+
// Ordering is important here. `npm install` must come first.
14+
var cmdArgs = [
15+
{ cmd: 'npm', args: ['install'] },
16+
{ cmd: 'webpack', args: ['index.js'] }
17+
];
18+
19+
for (let dir of exampleDirs) {
20+
let opts = {
21+
cwd: path.join(__dirname, dir),
22+
stdio: 'inherit'
23+
};
24+
25+
for (let cmdArg of cmdArgs) {
26+
let result = spawnSync(cmdArg.cmd, cmdArg.args, opts);
27+
if (result.status !== 0) {
28+
throw new Error('Building examples exited with non-zero');
29+
}
30+
}
31+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"check": "npm run lint && npm run test",
1313
"build:lib": "babel src --out-dir lib",
1414
"build:umd": "webpack src/index.js dist/redux.js && NODE_ENV=production webpack src/index.js dist/redux.min.js",
15+
"build:examples": "babel-node examples/buildAll.js",
1516
"build": "npm run build:lib && npm run build:umd",
1617
"preversion": "npm run clean && npm run check",
1718
"version": "npm run build",

0 commit comments

Comments
 (0)