diff --git a/src/nexe.ts b/src/nexe.ts index c2a196a..1c207f2 100644 --- a/src/nexe.ts +++ b/src/nexe.ts @@ -39,7 +39,6 @@ async function compile( if (error) { if (compiler.options.loglevel !== 'silent' && error) { - console.log(error) process.stderr.write(EOL + error.message + EOL) } compiler.quit() diff --git a/src/options.ts b/src/options.ts index 9f6433d..7ed897e 100644 --- a/src/options.ts +++ b/src/options.ts @@ -186,8 +186,15 @@ export function resolveEntry(input: string, cwd: string, maybeEntry?: string) { return '' } let result = null + if (input && isAbsolute(input)) { + return input + } if (input) { - result = resolveFileName(cwd, input, { silent: true }) + let prefix = '' + if (!input.startsWith('.')) { + prefix = './' + } + result = resolveFileName(cwd, prefix + input, { silent: true }) } if (isEntryFile(maybeEntry)) { result = resolveFileName(cwd, maybeEntry, { silent: true }) diff --git a/test/options.spec.ts b/test/options.spec.ts index 39ab679..b1434bc 100644 --- a/test/options.spec.ts +++ b/test/options.spec.ts @@ -14,6 +14,14 @@ describe('options', () => { const options = normalizeOptions() expect(options.input).to.equal(path.resolve('./index.js')) }) + it('should resolve relative paths for input', () => { + const options = normalizeOptions({ input: 'test/fixture/entry.js' }) + expect(options.input).to.equal(path.resolve('./test/fixture/entry.js')) + }) + it('should accept a module entry as input', () => { + const options = normalizeOptions({ input: 'test/fixture' }) + expect(options.input).to.equal(path.resolve('./test/fixture/entry.js')) + }) it('should resolve pathed options against cwd', () => { const cwd = path.join(process.cwd(), 'test/fixture') const options = normalizeOptions({