Update Vulcanize script for element tests

The Vulcanize script can now build the UI, the element test files, or
both, defaulting to the latter.

The `mkdirp` package is used as it's the simplest way of getting
recursive `mkdir`, ie. `mkdir -p`, to work.
This commit is contained in:
Oliver Hamlet
2016-03-05 11:49:26 +00:00
parent ccb5961dfb
commit 544e316be7
2 changed files with 32 additions and 3 deletions
+1
View File
@@ -23,6 +23,7 @@
"grunt-contrib-connect": "^0.11.2",
"grunt-contrib-watch": "^0.6.1",
"grunt-saucelabs": "^8.6.2",
"mkdirp": "^0.5.1",
"mocha": "^2.3.4",
"should": "^8.0.1",
"vulcanize": "^1.14.5"
+31 -3
View File
@@ -6,9 +6,15 @@ const path = require('path');
const fs = require('fs');
const helpers = require('./helpers');
const Vulcanize = require('vulcanize');
const mkdirp = require('mkdirp');
// Initialise from command line parameters.
let rootPath = '.';
if (process.argv.length > 2) {
let buildType = 'ui';
if (process.argv.length > 3) {
rootPath = process.argv[2];
buildType = process.argv[3];
} else if (process.argv.length > 2) {
rootPath = process.argv[2];
}
@@ -22,7 +28,7 @@ const vulcanize = new Vulcanize({
function mkdir(dir) {
try {
fs.mkdirSync(dir);
mkdirp.sync(dir);
} catch (e) {
if (e.code !== 'EEXIST') {
console.log(e);
@@ -51,4 +57,26 @@ function vulcanizeRelease(releasePath) {
vulcanizeFile(inputPath, outputPath);
}
helpers.getAppReleasePaths(rootPath).forEach(vulcanizeRelease);
function vulcanizeTests(releasePath) {
const inputPath = path.join(rootPath, 'src', 'tests', 'gui', 'html', 'elements');
const outputPath = path.join(releasePath.path, 'html_tests', 'elements');
const tests = [
'test_loot-custom-icons.html',
];
tests.forEach((test) => {
vulcanizeFile(path.join(inputPath, test), path.join(outputPath, test));
});
}
// Run the appropriate build(s).
const releasePaths = helpers.getAppReleasePaths(rootPath);
if (buildType === 'ui' || buildType === 'all') {
releasePaths.forEach(vulcanizeRelease);
}
if (buildType === 'tests' || buildType === 'all') {
releasePaths.forEach(vulcanizeTests);
}