Skip to content

Commit

Permalink
fix: build command (#71)
Browse files Browse the repository at this point in the history
* fix: build command

* lint fix
  • Loading branch information
marbemac authored May 12, 2021
1 parent 4fe19dd commit 4fa0d4f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ export const buildCommand = (
}: { defaultArgs?: any; rawArgs?: ParsingToken[]; flags?: string[] } = {},
) => {
// TODO: use matcher function to match baseCommand.cmd for Windows?
let command = findUp.sync(path.join('node_modules', '.bin', baseCommand), { cwd: process.cwd() });
if (!command) throw new Error(`Unable to locate node_modules/.bin binary for ${baseCommand}`);

// pull binary off the front, append rest of args back later
const [binary, ...commandArgs] = baseCommand.split(' ');

let command = findUp.sync(path.join('node_modules', '.bin', binary), {
cwd: process.cwd(),
});
if (!command) throw new Error(`Unable to locate node_modules/.bin binary for ${binary}`);

command = [command, ...commandArgs].join(' ');

for (const arg of rawArgs) {
if (!flags.includes(arg.input.substring(2))) command += ` ${arg.input}`;
Expand Down

0 comments on commit 4fa0d4f

Please sign in to comment.