Skip to content
This repository was archived by the owner on Jul 23, 2021. It is now read-only.

Commit 64fe9a0

Browse files
authored
platform independent build commands (#184)
* Add intellij files to gitignore * Use node native commands for build scripts
1 parent f6b62aa commit 64fe9a0

File tree

7 files changed

+68
-38
lines changed

7 files changed

+68
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ yarn-error.log
66
*~
77
*.swp
88
.idea
9+
*.iml
910
TODO
1011
/pages/out
1112
/pages/generated

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
"lint:ts": "tslint \"__tests__/**/*.ts\"",
3535
"lint:js": "eslint \"{__tests__,src,pages/src,pages/lib}/**/*.js\"",
3636
"format": "prettier --single-quote --trailing-comma=es5 --write \"{__tests__,src,pages/src,pages/lib,perf,resources}/**/*{.js,.ts}\"",
37-
"testonly": "./resources/jest.sh",
37+
"testonly": "jest --no-cache",
3838
"test": "run-s format build lint testonly test:types:*",
39-
"test:travis": "npm run test && ./resources/check-changes",
39+
"check-changes": "node ./resources/check-changes.js",
40+
"test:travis": "run-s format build lint \"testonly -i\" test:types:* check-changes",
4041
"test:types:ts": "tsc ./type-definitions/Immutable.d.ts --lib es2015 && dtslint type-definitions/ts-tests",
4142
"test:types:flow": "flow check type-definitions/tests --include-warnings",
4243
"perf": "node ./resources/bench.js",

resources/check-changes

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

resources/check-changes.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* This source code is licensed under the MIT license found in the
3+
* LICENSE file in the root directory of this source tree.
4+
*/
5+
6+
const { exec } = require('child_process');
7+
require('colors');
8+
9+
const checkForChanges = () =>
10+
new Promise(resolve =>
11+
exec(`git diff --quiet`, error => {
12+
if (error) {
13+
console.log(
14+
'The Travis build resulted in additional changed files.'.red
15+
);
16+
console.log(
17+
'Typically this is due to not running "npm test"" locally before submitting a pull request.'
18+
);
19+
return exec(`git diff --stat`, (diffError, diffOut) => {
20+
console.log('\nThe following changes were found:'.red);
21+
console.log(diffOut.yellow);
22+
process.exit(1);
23+
});
24+
}
25+
resolve();
26+
})
27+
);
28+
29+
return checkForChanges();

resources/dist-stats.js

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,37 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
const path = require('path');
98
const { exec } = require('child_process');
9+
const { deflate } = require('zlib');
10+
const fs = require('fs');
1011

1112
require('colors');
1213

13-
const execp = cmd =>
14+
const fileContent = filePath =>
1415
new Promise((resolve, reject) =>
15-
exec(cmd, (error, out) => (error ? reject(error) : resolve(out)))
16+
fs.readFile(
17+
filePath,
18+
(error, out) => (error ? reject(error) : resolve(out))
19+
)
20+
);
21+
22+
const gitContent = gitPath =>
23+
new Promise(resolve =>
24+
exec(`git show ${gitPath}`, (error, out) => {
25+
if (error) {
26+
console.log(
27+
`"git show ${gitPath}" failed, resulting in an empty diff.`.yellow
28+
);
29+
resolve('');
30+
return;
31+
}
32+
resolve(out);
33+
})
34+
);
35+
36+
const deflateContent = content =>
37+
new Promise((resolve, reject) =>
38+
deflate(content, (error, out) => (error ? reject(error) : resolve(out)))
1639
);
1740

1841
const space = (n, s) =>
@@ -29,13 +52,14 @@ const diff = (n, o) => {
2952
const pct = (s, b) => ` ${Math.floor(10000 * (1 - s / b)) / 100}%`.grey;
3053

3154
Promise.all([
32-
execp('cat dist/immutable.js | wc -c'),
33-
execp('git show master:dist/immutable.js | wc -c'),
34-
execp('cat dist/immutable.min.js | wc -c'),
35-
execp('git show master:dist/immutable.min.js | wc -c'),
36-
execp('cat dist/immutable.min.js | gzip -c | wc -c'),
37-
execp('git show master:dist/immutable.min.js | gzip -c | wc -c'),
55+
fileContent('dist/immutable.js'),
56+
gitContent('origin/npm:dist/immutable.js'),
57+
fileContent('dist/immutable.min.js'),
58+
gitContent('origin/npm:dist/immutable.min.js'),
59+
fileContent('dist/immutable.min.js').then(deflateContent),
60+
gitContent('origin/npm:dist/immutable.min.js').then(deflateContent),
3861
])
62+
.then(results => results.map(result => Buffer.byteLength(result, 'utf8')))
3963
.then(results => results.map(result => parseInt(result, 10)))
4064
.then(([rawNew, rawOld, minNew, minOld, zipNew, zipOld]) => {
4165
console.log(

resources/gulpfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ function reactPreRender(subDir) {
295295
'</script>'
296296
);
297297
}
298-
file.contents = new Buffer(src, enc);
298+
299+
file.contents = Buffer.from(src, enc);
299300
this.push(file);
300301
cb();
301302
});

resources/jest.sh

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

0 commit comments

Comments
 (0)