fix: use cwd directory name for output resolution before timestring

This commit is contained in:
calebboyd
2017-09-13 18:43:26 -05:00
parent 79bcb753b4
commit a2c4f3e9f1
3 changed files with 11 additions and 9 deletions
+4 -6
View File
@@ -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<string>`
export function createBundle (options: NexeOptions): Promise<string>`
```
- 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()}`
-1
View File
@@ -1,5 +1,4 @@
const nexe = require('../..')
nexe.compile({
output: 'native-build',
silent: true,
+7 -2
View File
@@ -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) {