From effd0f5adf32b6c9b050eee6b7f062e4ba978e8a Mon Sep 17 00:00:00 2001 From: Katrina Uychaco Date: Wed, 17 May 2017 10:56:54 +0200 Subject: [PATCH] WIP install dev dependencies when transpiling --- ...e-packages-with-custom-transpiler-paths.js | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/script/lib/transpile-packages-with-custom-transpiler-paths.js b/script/lib/transpile-packages-with-custom-transpiler-paths.js index 354a00a12..73f4a0b6e 100644 --- a/script/lib/transpile-packages-with-custom-transpiler-paths.js +++ b/script/lib/transpile-packages-with-custom-transpiler-paths.js @@ -1,29 +1,38 @@ 'use strict' const CompileCache = require('../../src/compile-cache') -const fs = require('fs') +const fs = require('fs-extra') const glob = require('glob') const path = require('path') const CONFIG = require('../config') +const runApmInstall = require('./run-apm-install') + +require('colors') + module.exports = function () { console.log(`Transpiling packages with custom transpiler configurations in ${CONFIG.intermediateAppPath}`) - let pathsToCompile = [] for (let packageName of Object.keys(CONFIG.appMetadata.packageDependencies)) { const packagePath = path.join(CONFIG.intermediateAppPath, 'node_modules', packageName) const metadataPath = path.join(packagePath, 'package.json') const metadata = require(metadataPath) if (metadata.atomTranspilers) { + console.log(' transpiling for package '.cyan + packageName.cyan) + const nodeModulesPath = path.join(packagePath, 'node_modules') + const nodeModulesBackupPath = path.join(packagePath, 'node_modules.bak') + fs.copySync(nodeModulesPath, nodeModulesBackupPath) + runApmInstall(packagePath) + CompileCache.addTranspilerConfigForPath(packagePath, metadata.name, metadata, metadata.atomTranspilers) for (let config of metadata.atomTranspilers) { - pathsToCompile = pathsToCompile.concat(glob.sync(path.join(packagePath, config.glob), {nodir: true})) + const pathsToCompile = glob.sync(path.join(packagePath, config.glob), {nodir: true}) + pathsToCompile.forEach(transpilePath) } - } - } - for (let path of pathsToCompile) { - transpilePath(path) + fs.removeSync(nodeModulesPath) + fs.renameSync(nodeModulesBackupPath, nodeModulesPath) + } } }