Skip to content

Commit ac7dd4a

Browse files
committed
[fixed] Postinstall script on Windows
1 parent 9d95102 commit ac7dd4a

File tree

5 files changed

+34
-10
lines changed

5 files changed

+34
-10
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"lint": "eslint modules examples",
1717
"start": "node examples/server.js",
1818
"test": "npm run lint && karma start",
19-
"postinstall": "node -e \"require('fs').stat('lib', function (e, s) { process.exit(e || !s.isDirectory() ? 1 : 0) })\" || npm run build"
19+
"postinstall": "node scripts/postinstall.js"
2020
},
2121
"authors": [
2222
"Ryan Florence",
@@ -40,6 +40,7 @@
4040
"expect": "^1.12.0",
4141
"express": "^4.13.3",
4242
"express-urlrewrite": "^1.2.0",
43+
"gzip-size": "^3.0.0",
4344
"karma": "^0.13.8",
4445
"karma-browserstack-launcher": "^0.1.4",
4546
"karma-chrome-launcher": "^0.2.0",
@@ -49,6 +50,7 @@
4950
"karma-sourcemap-loader": "^0.3.5",
5051
"karma-webpack": "^1.7.0",
5152
"mocha": "^2.0.1",
53+
"pretty-bytes": "^2.0.1",
5254
"qs": "^4.0.0",
5355
"react": "0.14.0",
5456
"react-addons-test-utils": "0.14.0",

scripts/build.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var execSync = require('child_process').execSync
2+
var readFileSync = require('fs').readFileSync
3+
var prettyBytes = require('pretty-bytes')
4+
var gzipSize = require('gzip-size')
5+
6+
function exec(command) {
7+
execSync(command, { stdio: [0, 1, 2] })
8+
}
9+
10+
exec('npm run build')
11+
exec('npm run build-umd')
12+
exec('npm run build-min')
13+
14+
console.log(
15+
'\ngzipped, the UMD build is ' + prettyBytes(
16+
gzipSize.sync(readFileSync('umd/ReactRouter.min.js'))
17+
)
18+
)

scripts/build.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/postinstall.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var execSync = require('child_process').execSync
2+
var stat = require('fs').stat
3+
4+
function exec(command) {
5+
execSync(command, { stdio: [0, 1, 2] })
6+
}
7+
8+
stat('lib', function (error, stat) {
9+
if (error || !stat.isDirectory())
10+
exec('npm run build')
11+
})

scripts/release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
changelog=node_modules/.bin/changelog
44

5-
if ! [ -e scripts/build.sh ]; then
5+
if ! [ -e scripts/build.js ]; then
66
echo >&2 "Please run scripts/release.sh from the repo root"
77
exit 1
88
fi
@@ -43,7 +43,7 @@ git push origin master
4343
git push origin $next_ref
4444
git push origin latest -f
4545

46-
./scripts/build.sh
46+
node scripts/build.js
4747

4848
# This is a workaround for a nasty npm bug. :'(
4949
# First, we need to uninstall the history package so

0 commit comments

Comments
 (0)