Skip to content

Commit

Permalink
fix(cli): terminate watch mode via esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
unicornware committed Apr 8, 2023
1 parent 767edd2 commit 34ef996
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
"jsonc-eslint-parser": "2.2.0",
"lint-staged": "13.2.0",
"memfs": "3.5.0",
"mri": "1.2.0",
"nest-commander": "3.6.1",
"nest-commander-testing": "3.1.0",
"node-notifier": "10.0.1",
Expand Down
14 changes: 12 additions & 2 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @module mkbuild/cli
*/

import mri from 'mri'
import { CommandFactory } from 'nest-commander'
import AppModule from './app.module'
import { CLI_NAME } from './constants'
Expand All @@ -26,6 +27,15 @@ async function main(): Promise<void> {
}))
}

// run application and exit
// run application
void (await main())
process.exit()

// check if watch mode is enabled
const { watch } = mri<{ watch: boolean }>(process.argv.slice(2), {
alias: { watch: 'w' },
boolean: ['watch'],
default: { write: false }
})

// exit if watch mode is not enabled
!watch && process.exit()
27 changes: 21 additions & 6 deletions src/plugins/fully-specified/__snapshots__/plugin.integration.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,63 @@

exports[`integration:plugins/fully-specified > esbuild > should fill specifiers in output files 1`] = `
[
{
"assertion": "",
"code": "import mri from \\"mri\\"",
"end": 41,
"imports": [
"mri",
],
"kind": "import",
"specifier": "mri",
"specifier_kind": "bare",
"specifier_syntax": "static",
"start": 20,
"syntax": "default",
"type": false,
},
{
"assertion": "",
"code": "import { CommandFactory } from \\"nest-commander\\"",
"end": 67,
"end": 90,
"imports": [
"CommandFactory",
],
"kind": "import",
"specifier": "nest-commander",
"specifier_kind": "bare",
"specifier_syntax": "static",
"start": 20,
"start": 43,
"syntax": "named",
"type": false,
},
{
"assertion": "",
"code": "import AppModule from \\"./app.module.mjs\\"",
"end": 109,
"end": 132,
"imports": [
"AppModule",
],
"kind": "import",
"specifier": "./app.module.mjs",
"specifier_kind": "relative",
"specifier_syntax": "static",
"start": 69,
"start": 92,
"syntax": "default",
"type": false,
},
{
"assertion": "",
"code": "import { CLI_NAME } from \\"./constants.mjs\\"",
"end": 153,
"end": 176,
"imports": [
"CLI_NAME",
],
"kind": "import",
"specifier": "./constants.mjs",
"specifier_kind": "relative",
"specifier_syntax": "static",
"start": 111,
"start": 134,
"syntax": "named",
"type": false,
},
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,7 @@ __metadata:
lint-staged: "npm:13.2.0"
memfs: "npm:3.5.0"
merge-anything: "npm:5.1.4"
mri: "npm:1.2.0"
nest-commander: "npm:3.6.1"
nest-commander-testing: "npm:3.1.0"
node-notifier: "npm:10.0.1"
Expand Down Expand Up @@ -6753,6 +6754,13 @@ __metadata:
languageName: node
linkType: hard

"mri@npm:1.2.0":
version: 1.2.0
resolution: "mri@npm:1.2.0"
checksum: f459cd82edbe77b6296cc59a5005c351cd52f6a6d733539ae91f6dbc61a23c6e558bf9dea2703212b2caf1b0803852f357325612ba848795686577432740bd49
languageName: node
linkType: hard

"mrmime@npm:^1.0.0":
version: 1.0.1
resolution: "mrmime@npm:1.0.1"
Expand Down

0 comments on commit 34ef996

Please sign in to comment.