Skip to content

Commit

Permalink
Support compiling on Windows (#947)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dplewis authored Oct 10, 2019
1 parent 18fd502 commit 55e5bd2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 24 deletions.
51 changes: 51 additions & 0 deletions build_releases.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const pkg = require('./package.json');
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');

const rmDir = function(dirPath) {
if(fs.existsSync(dirPath)) {
const files = fs.readdirSync(dirPath);
files.forEach(function(file) {
const curPath = path.join(dirPath, file);
if(fs.lstatSync(curPath).isDirectory()) {
rmDir(curPath);
} else {
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(dirPath);
}
};

const exec = function(cmd) {
execSync(cmd, { stdio: 'inherit' });
};

console.log(`Building JavaScript SDK v${pkg.version}...\n`)

console.log('Cleaning up old builds...\n');

rmDir(path.join(__dirname, 'dist'));
rmDir(path.join(__dirname, 'lib'));

const crossEnv = 'npm run cross-env';
const gulp = 'npm run gulp';

console.log('Browser Release:');
exec(`${crossEnv} PARSE_BUILD=browser ${gulp} compile`);

console.log('Weapp Release:');
exec(`${crossEnv} PARSE_BUILD=weapp ${gulp} compile`);

console.log('Node.js Release:');
exec(`${crossEnv} PARSE_BUILD=node ${gulp} compile`);

console.log('React Native Release:');
exec(`${crossEnv} PARSE_BUILD=react-native ${gulp} compile`);

console.log('Bundling and minifying for CDN distribution:');
exec(`${gulp} browserify`);
exec(`${gulp} browserify-weapp`);
exec(`${gulp} minify`);
exec(`${gulp} minify-weapp`);
21 changes: 0 additions & 21 deletions build_releases.sh

This file was deleted.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
"vinyl-source-stream": "2.0.0"
},
"scripts": {
"build": "./build_releases.sh",
"release": "./build_releases.sh && npm publish",
"build": "node build_releases.js",
"release": "node build_releases.js && npm publish",
"test": "cross-env PARSE_BUILD=node jest",
"lint": "eslint --cache src/ integration/",
"lint:fix": "eslint --fix --cache src/ integration/",
Expand All @@ -85,7 +85,9 @@
"integration": "cross-env TESTING=1 jasmine --config=jasmine.json",
"docs": "jsdoc -c ./jsdoc-conf.json ./src",
"prepare": "npm run build",
"release_docs": "./release_docs.sh"
"release_docs": "./release_docs.sh",
"gulp": "gulp",
"cross-env": "cross-env"
},
"jest": {
"automock": true,
Expand Down

0 comments on commit 55e5bd2

Please sign in to comment.