forked from tableau/wdclib
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake_version.js
More file actions
executable file
·52 lines (40 loc) · 1.75 KB
/
make_version.js
File metadata and controls
executable file
·52 lines (40 loc) · 1.75 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
var program = require('commander');
var BuildNumber = require('./DevUtils/BuildNumber.js');
var execSync = require('child_process').execSync;
var fs = require('fs-extra');
var path = require('path');
// wrap everything in a try catch so we can log any errors we see
try {
console.log("Running build");
execSync('npm run-script build');
console.log("Running build minify");
execSync('npm run-script build_min');
console.log("Done runing build processes");
// Copying files over
var buildNumber = new BuildNumber.VersionNumber(BuildNumber.getBuildNumber());
// Build up the names for the regular and minified versions of the file
var newFullFileName = BuildNumber.WDC_LIB_PREFIX + buildNumber.toString() + ".js";
var newMinFileName = BuildNumber.WDC_LIB_PREFIX + buildNumber.toString() + ".min.js";
// Build up the names for the latest versions of the file
var latestBuildName = buildNumber.major + "." + buildNumber.minor + ".latest";
var newLatestFullFileName = BuildNumber.WDC_LIB_PREFIX + latestBuildName + ".js";
var newLatestMinFileName = BuildNumber.WDC_LIB_PREFIX + latestBuildName + ".min.js";
var copyPairs = [
{src: "bundle.js", dest: newFullFileName},
{src: "bundle.min.js", dest: newMinFileName},
{src: "bundle.js", dest: newLatestFullFileName},
{src: "bundle.min.js", dest: newLatestMinFileName},
];
// Go through and copy all the files
for(var pair of copyPairs) {
var srcPath = path.join(__dirname, ".", "dist", pair.src);
var dstPath = path.join(__dirname, '.', 'versions', pair.dest);
console.log("Copying '" + srcPath + "' to '" + dstPath + "'");
fs.copySync(srcPath, dstPath);
}
} catch(e) {
debugger;
console.error("Error encountered");
console.error(e.toString());
}