chore(scripts): normalize paths and include typeRoots for Windows (#11933)

Short description of what this resolves:

Allows our e2e tests to run on a Windows machine

Changes proposed in this pull request:

Normalize paths using path.join()
Add typeRoots to the root tsconfig file
Change the spawnedCommand based on the OS
Fixes: #11551
This commit is contained in:
Brandy Carney
2017-06-05 18:57:05 -04:00
committed by GitHub
parent cb5d505d64
commit ad40b3b86b
14 changed files with 54 additions and 43 deletions

View File

@ -1,4 +1,4 @@
import { spawn } from 'child_process';
import { spawn } from 'cross-spawn';
import { NODE_MODULES_ROOT, SRC_ROOT } from './constants';
import { src, dest } from 'gulp';
import { dirname, join } from 'path';
@ -60,7 +60,9 @@ export function createTempTsConfig(includeGlob: string[], target: string, module
config.compilerOptions = Object.assign(config.compilerOptions, overrideCompileOptions);
}
// TS represents paths internally with '/' and expects the tsconfig path to be in this format
let json = JSON.stringify(config, null, 2);
json = json.replace(/\\\\/g, '/');
const dirToCreate = dirname(pathToWriteFile);
ensureDirSync(dirToCreate);
@ -217,9 +219,11 @@ export function runAppScriptsServe(testOrDemoName: string, appEntryPoint: string
}
return new Promise((resolve, reject) => {
const args = ['./node_modules/.bin/ionic-app-scripts'].concat(scriptArgs);
console.log(`node ${args.join(' ')}`);
const spawnedCommand = spawn('node', args, {stdio: 'inherit'});
let pathToAppScripts = join(NODE_MODULES_ROOT, '.bin', 'ionic-app-scripts');
pathToAppScripts = process.platform === 'win32' ? pathToAppScripts + '.cmd' : pathToAppScripts;
const spawnedCommand = spawn(pathToAppScripts, scriptArgs, {stdio: 'inherit'});
console.log(`${pathToAppScripts} ${scriptArgs.join(' ')}`);
spawnedCommand.on('close', (code: number) => {
if (code === 0) {