From 6b918fff509ef602c79de6a180c6d451cd304566 Mon Sep 17 00:00:00 2001 From: Gant Date: Tue, 3 Apr 2018 18:42:44 -0500 Subject: [PATCH 1/2] when module flag is passed use those modules --- src/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index ed96bc3..cfe6529 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,9 @@ import { build } from 'gluegun' +import * as yargsParse from 'yargs-parser' module.exports = async (): Promise => { // setup the runtime - build() + const cli = build() .brand('solidarity') .src(__dirname) // local installs @@ -12,6 +13,14 @@ module.exports = async (): Promise => { .plugins(`${process.env.appdata}/npm/node_modules`, { matching: 'solidarity-*', hidden: true }) // Windows // for testing - force load a local plugin // .plugin('../solidarity-react-native') + + // when a module parameter is passed we take the plugins from there, too + const args = process.argv.slice(2) + const parsedArgs = yargsParse(args) + const moduleName = parsedArgs.m || parsedArgs.module + if (moduleName) cli.plugins(`./node_modules/${moduleName}/node_modules`, { matching: 'solidarity-*', hidden: true }) + + cli .create() .run() } From 6637384d5d9356380876656d2a7021ebce9893df Mon Sep 17 00:00:00 2001 From: Gant Date: Tue, 3 Apr 2018 18:55:39 -0500 Subject: [PATCH 2/2] fixup es6 for testing --- __tests__/command_helpers/getSolidaritySettings.ts | 5 +---- src/index.ts | 12 ++++-------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/__tests__/command_helpers/getSolidaritySettings.ts b/__tests__/command_helpers/getSolidaritySettings.ts index 1b15d8c..c678e75 100644 --- a/__tests__/command_helpers/getSolidaritySettings.ts +++ b/__tests__/command_helpers/getSolidaritySettings.ts @@ -38,11 +38,10 @@ describe('basic getSolidaritySettings', () => { }).toThrowError('ERROR: Found, but no requirements key. Please validate your solidarity file') process.chdir('../../../') }) - } + }) }) describe('parameterized getSolidaritySettings', () => { - test('custom path with -f', () => { context.parameters.options = { f: '__tests__/sandbox/solidarity_json' } const resultSettings = getSolidaritySettings(context) @@ -113,7 +112,5 @@ describe('parameterized getSolidaritySettings', () => { afterAll(() => { process.chdir('../../../') }) - }) - }) diff --git a/src/index.ts b/src/index.ts index cfe6529..93b8282 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ import { build } from 'gluegun' -import * as yargsParse from 'yargs-parser' module.exports = async (): Promise => { // setup the runtime @@ -11,18 +10,15 @@ module.exports = async (): Promise => { // global installs .plugins('/usr/local/lib/node_modules', { matching: 'solidarity-*', hidden: true }) // Darwin .plugins(`${process.env.appdata}/npm/node_modules`, { matching: 'solidarity-*', hidden: true }) // Windows - // for testing - force load a local plugin - // .plugin('../solidarity-react-native') + // for testing - force load a local plugin + // .plugin('../solidarity-react-native') // when a module parameter is passed we take the plugins from there, too - const args = process.argv.slice(2) - const parsedArgs = yargsParse(args) + const parsedArgs = require('yargs-parser')(process.argv.slice(2)) const moduleName = parsedArgs.m || parsedArgs.module if (moduleName) cli.plugins(`./node_modules/${moduleName}/node_modules`, { matching: 'solidarity-*', hidden: true }) - cli - .create() - .run() + cli.create().run() } export * from './types'