Skip to content

Commit 55e5bd2

Browse files
authored
Support compiling on Windows (#947)
* Support compiling on Windows Converts bash script to node script. No longer requires gulp to be installed globally. Fixes: #925 @JeromeDeLeon Can you test if this works? * replace directory with cmd * clean up
1 parent 18fd502 commit 55e5bd2

File tree

3 files changed

+56
-24
lines changed

3 files changed

+56
-24
lines changed

build_releases.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const pkg = require('./package.json');
2+
const fs = require('fs');
3+
const path = require('path');
4+
const { execSync } = require('child_process');
5+
6+
const rmDir = function(dirPath) {
7+
if(fs.existsSync(dirPath)) {
8+
const files = fs.readdirSync(dirPath);
9+
files.forEach(function(file) {
10+
const curPath = path.join(dirPath, file);
11+
if(fs.lstatSync(curPath).isDirectory()) {
12+
rmDir(curPath);
13+
} else {
14+
fs.unlinkSync(curPath);
15+
}
16+
});
17+
fs.rmdirSync(dirPath);
18+
}
19+
};
20+
21+
const exec = function(cmd) {
22+
execSync(cmd, { stdio: 'inherit' });
23+
};
24+
25+
console.log(`Building JavaScript SDK v${pkg.version}...\n`)
26+
27+
console.log('Cleaning up old builds...\n');
28+
29+
rmDir(path.join(__dirname, 'dist'));
30+
rmDir(path.join(__dirname, 'lib'));
31+
32+
const crossEnv = 'npm run cross-env';
33+
const gulp = 'npm run gulp';
34+
35+
console.log('Browser Release:');
36+
exec(`${crossEnv} PARSE_BUILD=browser ${gulp} compile`);
37+
38+
console.log('Weapp Release:');
39+
exec(`${crossEnv} PARSE_BUILD=weapp ${gulp} compile`);
40+
41+
console.log('Node.js Release:');
42+
exec(`${crossEnv} PARSE_BUILD=node ${gulp} compile`);
43+
44+
console.log('React Native Release:');
45+
exec(`${crossEnv} PARSE_BUILD=react-native ${gulp} compile`);
46+
47+
console.log('Bundling and minifying for CDN distribution:');
48+
exec(`${gulp} browserify`);
49+
exec(`${gulp} browserify-weapp`);
50+
exec(`${gulp} minify`);
51+
exec(`${gulp} minify-weapp`);

build_releases.sh

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

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373
"vinyl-source-stream": "2.0.0"
7474
},
7575
"scripts": {
76-
"build": "./build_releases.sh",
77-
"release": "./build_releases.sh && npm publish",
76+
"build": "node build_releases.js",
77+
"release": "node build_releases.js && npm publish",
7878
"test": "cross-env PARSE_BUILD=node jest",
7979
"lint": "eslint --cache src/ integration/",
8080
"lint:fix": "eslint --fix --cache src/ integration/",
@@ -85,7 +85,9 @@
8585
"integration": "cross-env TESTING=1 jasmine --config=jasmine.json",
8686
"docs": "jsdoc -c ./jsdoc-conf.json ./src",
8787
"prepare": "npm run build",
88-
"release_docs": "./release_docs.sh"
88+
"release_docs": "./release_docs.sh",
89+
"gulp": "gulp",
90+
"cross-env": "cross-env"
8991
},
9092
"jest": {
9193
"automock": true,

0 commit comments

Comments
 (0)