1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- // Dependecies.
- const fs = require('fs-extra');
- const path = require('path');
- const rmDir = require("../../NodeHelpers/rmDir");
- const colorConsole = require("../../NodeHelpers/colorConsole");
- var shelljs = require("shelljs");
- // Global Variables.
- const config = require("../../Config/config.js");
- /**
- * Prepare an es6 Dev folder npm linked for test purpose.
- */
- function prepareEs6DevPackages() {
- config.modules.forEach(moduleName => {
- const module = config[moduleName];
- const es6Config = module.build.es6;
- colorConsole.log("Prepare " + "ES6Dev".magenta + " Package: " + moduleName.blue.bold);
- const packagePath = module.computed.packageES6Directory;
- const packageDevPath = module.computed.packageES6DevDirectory;
- colorConsole.log(" Cleanup " + packageDevPath.cyan);
- rmDir(packageDevPath);
- colorConsole.log(" Copy Package folder " + packagePath.cyan + " to " + packageDevPath.cyan);
- fs.copySync(packagePath, packageDevPath);
- const packageES6DevJSONPath = path.join(packageDevPath, "package.json");
- const packageES6DevJSON = require(packageES6DevJSONPath);
- for (let dependency in packageES6DevJSON.dependencies) {
- if (dependency.indexOf("@babylon") > -1) {
- colorConsole.log(" Execute Npm Link " + dependency.yellow);
- const command = `npm link ${dependency}`;
- const result = shelljs.exec(command, {
- async: false,
- cwd: packageDevPath
- });
- if (result.code != 0) {
- throw "Failed to link the ES6 package."
- }
- }
- }
- colorConsole.log(" Execute Npm Link command");
- const command = `npm link`;
- const result = shelljs.exec(command, {
- async: false,
- cwd: packageDevPath
- });
- if (result.code != 0) {
- throw "Failed to link the ES6 package."
- }
- colorConsole.emptyLine();
- });
- }
- /**
- * Main function driving the publication.
- */
- module.exports = prepareEs6DevPackages;
|