Skip to content

Commit 0642fe8

Browse files
committed
replace vendor_to_dist shell script with add empty_dist.js and topojson_dist.js to run before build scripts
1 parent fd427ec commit 0642fe8

File tree

4 files changed

+40
-14
lines changed

4 files changed

+40
-14
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
"plotly"
2222
],
2323
"scripts": {
24-
"preprocess": "./tasks/vendor_to_dist.sh && node tasks/preprocess.js",
24+
"preprocess": "node tasks/preprocess.js",
2525
"bundle": "node tasks/bundle.js",
2626
"header-dist": "node tasks/header_dist.js",
2727
"stats": "node tasks/stats.js",
2828
"find-strings": "node tasks/find_locale_strings.js",
29-
"build": "npm run preprocess && npm run find-strings && npm run bundle && npm run header-dist && npm run stats",
30-
"cibuild": "npm run preprocess && node tasks/cibundle.js",
29+
"build": "node tasks/empty_dist.js && npm run preprocess && node tasks/topojson_dist.js && npm run find-strings && npm run bundle && npm run header-dist && npm run stats",
30+
"cibuild": "node tasks/empty_dist.js && npm run preprocess && node tasks/cibundle.js",
3131
"watch": "node tasks/watch.js",
3232
"lint": "eslint --version && eslint .",
3333
"lint-fix": "eslint . --fix || true",

tasks/empty_dist.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var fs = require('fs-extra');
2+
var common = require('./util/common');
3+
var constants = require('./util/constants');
4+
5+
// main
6+
emptyDist();
7+
8+
function emptyDist() {
9+
var dir = constants.pathToDist;
10+
if(common.doesDirExist(dir)) {
11+
console.log('empty ' + dir);
12+
try {
13+
fs.rmdirSync(dir, { recursive: true });
14+
} catch(err) {
15+
console.error(err);
16+
}
17+
18+
// create folder
19+
fs.mkdirSync(dir);
20+
}
21+
}

tasks/topojson_dist.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var fs = require('fs-extra');
2+
var common = require('./util/common');
3+
var constants = require('./util/constants');
4+
5+
// main
6+
copyTopojsonFiles();
7+
8+
// copy topojson files from vendor/ to dist/
9+
function copyTopojsonFiles() {
10+
fs.copy(
11+
constants.pathToTopojsonVendor,
12+
constants.pathToTopojsonDist,
13+
{ clobber: true },
14+
common.throwOnError
15+
);
16+
}

tasks/vendor_to_dist.sh

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

0 commit comments

Comments
 (0)