Skip to content

Commit bc6233e

Browse files
committed
Change flush timeout & add environment variable to override
1 parent 5beabf3 commit bc6233e

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

cli/bin/dev

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
#!/usr/bin/env node
22

3-
const oclif = require('@oclif/core')
3+
const oclif = require("@oclif/core");
44

5-
const path = require('path')
6-
const project = path.join(__dirname, '..', 'tsconfig.json')
5+
const path = require("path");
6+
const project = path.join(__dirname, "..", "tsconfig.json");
77

88
// In dev mode -> use ts-node and dev plugins
9-
process.env.NODE_ENV = 'development'
9+
process.env.NODE_ENV = "development";
1010

11-
require('ts-node').register({project})
11+
require("ts-node").register({ project });
1212

1313
// In dev mode, always show stack traces
1414
oclif.settings.debug = true;
1515

16+
const flush = () => {
17+
const passed = parseInt(process.env.NS_CLI_FLUSH_TIMEOUT);
18+
const timeout = passed > 0 && !isNaN(passed) ? passed : 100000000;
19+
oclif.flush(Math.min(timeout * 1000, 0x7fffffff)); // setTimeout requires signed 32 bit integer range
20+
};
21+
1622
// Start the CLI
17-
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
23+
oclif.run().then(flush).catch(oclif.Errors.handle);

cli/bin/run

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/usr/bin/env node
22

3-
const oclif = require('@oclif/core')
3+
const oclif = require("@oclif/core");
44

5-
oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))
5+
const flush = () => {
6+
const passed = parseInt(process.env.NS_CLI_FLUSH_TIMEOUT);
7+
const timeout = passed > 0 && !isNaN(passed) ? passed : 100000000;
8+
require("@oclif/core/flush")(Math.min(timeout * 1000, 0x7fffffff)); // setTimeout requires signed 32 bit integer range
9+
};
10+
11+
oclif.run().then(flush).catch(require("@oclif/core/handle"));

0 commit comments

Comments
 (0)