npm package development run executable

孤街浪徒 提交于 2020-01-25 06:52:07

问题


I'm creating a module (foo) with an executable. I've used npm link to make sure the package can be tested locally. This module has a dependency (bar) with an executable. I want to access this executable inside my executable.

mainProject
|
|- foo
   |
   |- bar




// cli.js (foo/cli.js)
import { spawnSync } from 'child_process';

async function main(argv: string[]) {
    const version = require('../package.json').version;

    commander
        .command('test')
        .action(async () => {
            const { stdout, stderr, error } = spawnSync('bar --help');
        });

    commander.parse(argv);
}

export default main;

If I call foo test from my main project it fails I get:

Error: spawnSync bar --help ENOENT

来源:https://stackoverflow.com/questions/59357144/npm-package-development-run-executable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!