oclif

Cannot find Typescript module even though tsc successfully manages to resolve it

自作多情 提交于 2020-01-29 09:11:27
问题 I have a Node.js project written in Typescript which is expected to run as a CLI, and am having trouble to import a module located out of the node_modules directory using an absolute path (relative paths work fine). It might be important to mention that I am using the oclif framework for building my CLI. My project is organized as follows: cli |--node_modules |--src |--my-module.ts |--subdir |--index.ts Within my-module.ts I have: export class MyClass { myClassFcn(s: string) { return 'result'

Oclif prompt testing

痴心易碎 提交于 2020-01-04 02:47:11
问题 I'm attempting to write a unit test for an Oclif hook that contains a simple prompt. I want to test the output of the hook, given a 'Y' or 'N' response to the prompt. import {Hook} from '@oclif/config' import cli from 'cli-ux' const hook: Hook<'init'> = async function () { const answer = await cli.prompt("Y or N?") if(answer === 'Y') { this.log('yes') } else { this.log('no') } } export default hook I'm using the 'fancy-test' and '@oclif/test' test frameworks described here: https://oclif.io