All files / wdclib make_version.js

0% Statements 0/11
0% Branches 0/2
100% Functions 0/0
0% Lines 0/11
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 51 52 53 54                                                                                                           
 
/* globals __dirname, require */
 
import { VersionNumber, getBuildNumber, WDC_LIB_PREFIX } from './DevUtils/BuildNumber';
import fs from 'fs-extra';
import path from 'path';
 
let execSync = require('child_process').execSync;
 
// wrap everything in a try catch so we can log any errors we see
try {
    console.log('\n\nMake version is running -> build');
    execSync('npm run-script build');
 
    console.log('\n\nMake version is running -> build minify');
    execSync('npm run-script build_min');
 
    console.log('\n\nMake version -> Done runing build processes');
 
    // Prepare version number
    let versionNumber = new VersionNumber(getBuildNumber());
 
    // Build up the name for the regular and minified versions of the file
    let fullVersionName = `${WDC_LIB_PREFIX}${versionNumber.toString()}`;
 
    // Build up the names for the latest versions of the file
    let latestBuildName = `${WDC_LIB_PREFIX}${versionNumber.major}.${versionNumber.minor}.latest`;
 
    let copyPairs = [
        { src: 'bundle.js', dest: `${fullVersionName}.js` },
        { src: 'bundle.min.js', dest: `${fullVersionName}.min.js` },
        { src: 'bundle.js', dest: `${latestBuildName}.js` },
        { src: 'bundle.min.js', dest: `${latestBuildName}.min.js` }
    ];
 
    console.log('\n\nMake version -> Copy files to destination');
    // Go through and copy all the files
    for (let pair of copyPairs) {
        let srcPath = path.join(__dirname, '.', 'dist', pair.src);
        let dstPath = path.join(__dirname, '.', 'versions', pair.dest);
 
        console.log(`Copying ${srcPath} to ${dstPath}`);
 
        fs.copySync(srcPath, dstPath);
    }
 
    console.log('\n\nMake version done -> ♥ \n\n');
 
} catch (e) {
    debugger; // eslint-disable-line no-debugger
    console.error('Error encountered');
    console.error(e.toString());
}