Skip to content

Commit

Permalink
[Fix] travis build failing with Node 13.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nonara committed Nov 28, 2019
1 parent 02e53e6 commit 66d51c6
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/lib/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import * as shell from 'shelljs';
import { patchTSModule } from './patcher';
import { getModuleAbsolutePath, getTSModule, getTSPackage, mkdirIfNotExist, TSModule, TSPackage } from './file-utils';
import {
TSPOptions, Log, parseOptions, PatchError, RestoreError, resetOptions, defineProperties, BackupError,
PersistenceError, tspPackageJSON, appRoot, NPMError
appRoot, BackupError, defineProperties, Log, NPMError, parseOptions, PatchError, PersistenceError, resetOptions,
RestoreError, TSPOptions, tspPackageJSON
} from './system';
import resolve = require('resolve');

Expand Down Expand Up @@ -145,13 +145,28 @@ function installDependencies(tsPackage: TSPackage) {

/* Install missing dependencies */
const missingDeps = getDependenciesDetail().filter(({version}) => !version);

if (missingDeps.length > 0) {
Log(['~', `Installing dependencies: ${missingDeps.map(({name}) => name).join(', ')} (via npm)...`], Log.verbose);

/*
* Note: The environment variable is used here to compensate for an issue within istanbuljs/spawn-wrap
* When nyc coverage is run, spawn-wrap replaces any instance of the word 'node' in command string with an absolute
* path to its node installation. As a result, ts-node cannot install.
*
* This workaround will be replaced shortly.
*/
shell.exec(
`npm i ${missingDeps.map(({name}) => name).join(' ')}`,
{ cwd: path.resolve(tsPackage.packageDir, '..') }
`npm i --no-audit ${ process.platform === 'win32' ? '%PACKAGES%' : '$PACKAGES' }`,
{
cwd: path.resolve(tsPackage.packageDir, '..'),
env: {
...process.env,
PACKAGES: missingDeps.map(({name}) => name).join(' ')
}
}
);

if (shell.error()) throw new NPMError(`Error while installing dependencies: ${shell.error()}`);
}

Expand Down

0 comments on commit 66d51c6

Please sign in to comment.