From a2c4f3e9f134806f2aab497c09ab203d082c9f46 Mon Sep 17 00:00:00 2001 From: calebboyd Date: Wed, 13 Sep 2017 18:43:26 -0500 Subject: [PATCH] fix: use cwd directory name for output resolution before timestring --- README.md | 10 ++++------ examples/native-build/build.js | 1 - src/options.ts | 9 +++++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fa3313a..4e6f873 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,9 @@ compile({ console.log('success') }) ``` +## NexeOptions -### `options` +### `options: object` - #### `input: string` - Input bundle file path @@ -88,12 +89,9 @@ compile({ - If a string is provided it must be a valid relative module path and should provide an export with the following signature: ```typescript - export function createBundle ( - filename: string, - options: { name: string, minify: any, cwd: string } - ): Promise` + export function createBundle (options: NexeOptions): Promise` ``` - - default: true, uses the internal fuse-box configuration + - default: true - #### `name: string` - Module friendly name of the application - default: basename of the input file, or `nexe_${Date.now()}` diff --git a/examples/native-build/build.js b/examples/native-build/build.js index 833f5ee..c4e7780 100644 --- a/examples/native-build/build.js +++ b/examples/native-build/build.js @@ -1,5 +1,4 @@ const nexe = require('../..') - nexe.compile({ output: 'native-build', silent: true, diff --git a/src/options.ts b/src/options.ts index f7ed259..753c086 100644 --- a/src/options.ts +++ b/src/options.ts @@ -1,7 +1,7 @@ import * as parseArgv from 'minimist' import { NexeCompiler } from './compiler' import { isWindows, padRight } from './util' -import { basename, extname, join, isAbsolute, relative } from 'path' +import { basename, extname, join, isAbsolute, relative, dirname } from 'path' import { getTarget, NexeTarget } from './target' import { EOL } from 'os' import * as c from 'chalk' @@ -66,6 +66,7 @@ const defaults = { const alias = { i: 'input', o: 'output', + v: 'version', t: 'target', b: 'build', n: 'name', @@ -147,7 +148,11 @@ function tryResolveMainFileName(cwd: string) { filename = basename(file).replace(extname(file), '') } catch (_) {} - return !filename || filename === 'index' ? 'nexe_' + Date.now() : filename + if (filename === 'index' && basename(cwd)) { + return basename(cwd) + } + + return filename ? filename : 'nexe_' + Date.now() } function extractLogLevel(options: NexeOptions) {