From 0a75d62216b1015686984c89f719262dbf5f2f6b Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Mon, 30 Apr 2018 16:51:20 -0700 Subject: [PATCH] fix: use require.resolve to find globby and ts-node --- .circleci/config.yml | 1 - src/plugin.ts | 3 ++- src/ts_node.ts | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 300df469..3947b903 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,7 +15,6 @@ jobs: - v1-yarn-{{checksum ".circleci/config.yml"}} - run: .circleci/greenkeeper - run: yarn add -D nyc@11 @oclif/nyc-config@0 - - run: cd test/fixtures/typescript && yarn - run: | $NYC yarn test $NYC report --reporter text-lcov > coverage.lcov diff --git a/src/plugin.ts b/src/plugin.ts index aac85dae..0cc48589 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -123,7 +123,8 @@ export class Plugin implements IPlugin { if (!this.commandsDir) return [] let globby: typeof Globby try { - globby = require(`${this.root}/node_modules/globby`) + const globbyPath = require.resolve('globby', {paths: [this.root, __dirname]}) + globby = require(globbyPath) } catch (err) { this.warn(err, 'not loading commands, globby not found') return [] diff --git a/src/ts_node.ts b/src/ts_node.ts index f82cf798..7503f5c8 100644 --- a/src/ts_node.ts +++ b/src/ts_node.ts @@ -24,7 +24,8 @@ function registerTSNode(root: string) { const tsconfig = loadTSConfig(root) if (!tsconfig) return debug('registering ts-node at', root) - const tsNode: typeof TSNode = require(`${root}/node_modules/ts-node`) + const tsNodePath = require.resolve('ts-node', {paths: [root, __dirname]}) + const tsNode: typeof TSNode = require(tsNodePath) tsconfigs[root] = tsconfig typeRoots.push(`${root}/node_modules/@types`) if (tsconfig.compilerOptions.rootDirs) {