forked from plotly/plotly.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathempty_dist.js
More file actions
36 lines (32 loc) · 868 Bytes
/
empty_dist.js
File metadata and controls
36 lines (32 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var path = require('path');
var fs = require('fs-extra');
var common = require('./util/common');
var constants = require('./util/constants');
var dist = constants.pathToDist; // dist
var distTopojson = constants.pathToTopojsonDist; // dist/topojson
// main
emptyDir(distTopojson);
emptyDir(dist);
makeDir(dist);
makeDir(distTopojson);
function emptyDir(dir) {
if(common.doesDirExist(dir)) {
console.log('empty ' + dir);
try {
var allFiles = fs.readdirSync(dir);
allFiles.forEach(function(file) {
// remove file
fs.unlinkSync(path.join(dir, file));
});
fs.rmdirSync(dir);
} catch(err) {
console.error(err);
}
}
}
function makeDir(dir) {
if(!common.doesDirExist(dir)) {
// create folder
fs.mkdirSync(dir);
}
}