@alterior/terminal 3.6.7 → 3.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -3
- package/dist/index.js +20 -19
- package/dist/index.js.map +1 -1
- package/dist/read/basic.test.d.ts +1 -1
- package/dist/read/basic.test.js +54 -54
- package/dist/read/basic.test.js.map +1 -1
- package/dist/read/fixtures.d.ts +4 -4
- package/dist/read/fixtures.js +30 -31
- package/dist/read/fixtures.js.map +1 -1
- package/dist/read/index.d.ts +1 -1
- package/dist/read/index.js +17 -17
- package/dist/read/many.test.d.ts +1 -1
- package/dist/read/many.test.js +34 -34
- package/dist/read/many.test.js.map +1 -1
- package/dist/read/read.d.ts +40 -41
- package/dist/read/read.js +74 -75
- package/dist/read/read.js.map +1 -1
- package/dist/style.d.ts +48 -48
- package/dist/style.js +74 -74
- package/dist/style.js.map +1 -1
- package/dist/task-list.d.ts +110 -0
- package/dist/task-list.js +471 -0
- package/dist/task-list.js.map +1 -0
- package/dist/terminal-ui.d.ts +24 -26
- package/dist/terminal-ui.js +94 -94
- package/dist/terminal-ui.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/dist/test.js +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +6 -5
- package/src/index.ts +2 -1
- package/src/task-list.ts +590 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export * from './style';
|
|
2
|
-
export * from './read';
|
|
3
|
-
export * from './terminal-ui';
|
|
1
|
+
export * from './style';
|
|
2
|
+
export * from './read';
|
|
3
|
+
export * from './terminal-ui';
|
|
4
|
+
export * from './task-list';
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./style"), exports);
|
|
18
|
-
__exportStar(require("./read"), exports);
|
|
19
|
-
__exportStar(require("./terminal-ui"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./style"), exports);
|
|
18
|
+
__exportStar(require("./read"), exports);
|
|
19
|
+
__exportStar(require("./terminal-ui"), exports);
|
|
20
|
+
__exportStar(require("./task-list"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,yCAAuB;AACvB,gDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,yCAAuB;AACvB,gDAA8B;AAC9B,8CAA4B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/dist/read/basic.test.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const chai_1 = require("chai");
|
|
4
|
-
const razmin_1 = require("razmin");
|
|
5
|
-
const fixtures_1 = require("./fixtures");
|
|
6
|
-
const read_1 = require("./read");
|
|
7
|
-
if (process.argv[2] === 'child') {
|
|
8
|
-
child();
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
(0, razmin_1.describe)('read', it => {
|
|
12
|
-
it('basic', async () => {
|
|
13
|
-
const { stdout, stderr } = await (0, fixtures_1.spawnRead)(__filename, {
|
|
14
|
-
'Username: (test-user)': 'a user',
|
|
15
|
-
'Password: (<default hidden>)': 'a password',
|
|
16
|
-
'Password again: (<default hidden>)': 'a password',
|
|
17
|
-
});
|
|
18
|
-
(0, chai_1.expect)(JSON.parse(stderr)).to.eql({ user: 'a user', pass: 'a password', verify: 'a password', passMatch: true });
|
|
19
|
-
(0, chai_1.expect)(stdout).to.equal('Username: (test-user) Password: (<default hidden>) Password again: (<default hidden>) ');
|
|
20
|
-
});
|
|
21
|
-
it('defaults', async () => {
|
|
22
|
-
const { stdout, stderr } = await (0, fixtures_1.spawnRead)(__filename, {
|
|
23
|
-
'Username: (test-user)': '',
|
|
24
|
-
'Password: (<default hidden>)': '',
|
|
25
|
-
'Password again: (<default hidden>)': '',
|
|
26
|
-
});
|
|
27
|
-
(0, chai_1.expect)(JSON.parse(stderr)).to.eql({ user: 'test-user', pass: 'test-pass', verify: 'test-pass', passMatch: true });
|
|
28
|
-
(0, chai_1.expect)(stdout).to.equal('Username: (test-user) Password: (<default hidden>) Password again: (<default hidden>) ');
|
|
29
|
-
});
|
|
30
|
-
it('errors', async () => {
|
|
31
|
-
try {
|
|
32
|
-
await (0, read_1.read)({ default: {} });
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
throw new Error(`Expected rejection`);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
async function child() {
|
|
42
|
-
const user = await (0, read_1.read)({ prompt: 'Username: ', default: 'test-user' });
|
|
43
|
-
const pass = await (0, read_1.read)({ prompt: 'Password: ', default: 'test-pass', silent: true });
|
|
44
|
-
const verify = await (0, read_1.read)({ prompt: 'Password again: ', default: 'test-pass', silent: true });
|
|
45
|
-
console.error(JSON.stringify({
|
|
46
|
-
user,
|
|
47
|
-
pass,
|
|
48
|
-
verify,
|
|
49
|
-
passMatch: pass === verify,
|
|
50
|
-
}));
|
|
51
|
-
if (process.stdin.unref) {
|
|
52
|
-
process.stdin.unref();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const razmin_1 = require("razmin");
|
|
5
|
+
const fixtures_1 = require("./fixtures");
|
|
6
|
+
const read_1 = require("./read");
|
|
7
|
+
if (process.argv[2] === 'child') {
|
|
8
|
+
child();
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
(0, razmin_1.describe)('read', it => {
|
|
12
|
+
it('basic', async () => {
|
|
13
|
+
const { stdout, stderr } = await (0, fixtures_1.spawnRead)(__filename, {
|
|
14
|
+
'Username: (test-user)': 'a user',
|
|
15
|
+
'Password: (<default hidden>)': 'a password',
|
|
16
|
+
'Password again: (<default hidden>)': 'a password',
|
|
17
|
+
});
|
|
18
|
+
(0, chai_1.expect)(JSON.parse(stderr)).to.eql({ user: 'a user', pass: 'a password', verify: 'a password', passMatch: true });
|
|
19
|
+
(0, chai_1.expect)(stdout).to.equal('Username: (test-user) Password: (<default hidden>) Password again: (<default hidden>) ');
|
|
20
|
+
});
|
|
21
|
+
it('defaults', async () => {
|
|
22
|
+
const { stdout, stderr } = await (0, fixtures_1.spawnRead)(__filename, {
|
|
23
|
+
'Username: (test-user)': '',
|
|
24
|
+
'Password: (<default hidden>)': '',
|
|
25
|
+
'Password again: (<default hidden>)': '',
|
|
26
|
+
});
|
|
27
|
+
(0, chai_1.expect)(JSON.parse(stderr)).to.eql({ user: 'test-user', pass: 'test-pass', verify: 'test-pass', passMatch: true });
|
|
28
|
+
(0, chai_1.expect)(stdout).to.equal('Username: (test-user) Password: (<default hidden>) Password again: (<default hidden>) ');
|
|
29
|
+
});
|
|
30
|
+
it('errors', async () => {
|
|
31
|
+
try {
|
|
32
|
+
await (0, read_1.read)({ default: {} });
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`Expected rejection`);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async function child() {
|
|
42
|
+
const user = await (0, read_1.read)({ prompt: 'Username: ', default: 'test-user' });
|
|
43
|
+
const pass = await (0, read_1.read)({ prompt: 'Password: ', default: 'test-pass', silent: true });
|
|
44
|
+
const verify = await (0, read_1.read)({ prompt: 'Password again: ', default: 'test-pass', silent: true });
|
|
45
|
+
console.error(JSON.stringify({
|
|
46
|
+
user,
|
|
47
|
+
pass,
|
|
48
|
+
verify,
|
|
49
|
+
passMatch: pass === verify,
|
|
50
|
+
}));
|
|
51
|
+
if (process.stdin.unref) {
|
|
52
|
+
process.stdin.unref();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
55
|
//# sourceMappingURL=basic.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic.test.js","sourceRoot":"","sources":["../../src/read/basic.test.ts"],"names":[],"mappings":";;AAAA,+BAA6B;AAC7B,mCAAiC;AACjC,yCAAuC;AAEvC,iCAA8B;AAE9B,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"basic.test.js","sourceRoot":"","sources":["../../src/read/basic.test.ts"],"names":[],"mappings":";;AAAA,+BAA6B;AAC7B,mCAAiC;AACjC,yCAAuC;AAEvC,iCAA8B;AAE9B,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC;IAChC,KAAK,EAAE,CAAA;AACT,CAAC;KAAM,CAAC;IACN,IAAA,iBAAQ,EAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACpB,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;YACrB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,oBAAS,EAAC,UAAU,EAAE;gBACrD,uBAAuB,EAAE,QAAQ;gBACjC,8BAA8B,EAAE,YAAY;gBAC5C,oCAAoC,EAAE,YAAY;aACnD,CAAC,CAAA;YAEF,IAAA,aAAM,EAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACjH,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,wFAAwF,CAAC,CAAC;QACpH,CAAC,CAAC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AE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IAE7F,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;QAC3B,IAAI;QACJ,IAAI;QACJ,MAAM;QACN,SAAS,EAAE,IAAI,KAAK,MAAM;KAC3B,CAAC,CAAC,CAAA;IAEH,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACxB,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACvB,CAAC;AACH,CAAC"}
|
package/dist/read/fixtures.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function spawnRead(filename: any, writes: any): Promise<{
|
|
2
|
-
stdout: string;
|
|
3
|
-
stderr: string;
|
|
4
|
-
}>;
|
|
1
|
+
export declare function spawnRead(filename: any, writes: any): Promise<{
|
|
2
|
+
stdout: string;
|
|
3
|
+
stderr: string;
|
|
4
|
+
}>;
|
package/dist/read/fixtures.js
CHANGED
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.spawnRead =
|
|
4
|
-
const spawn = require('child_process').spawn;
|
|
5
|
-
const esc = (str) => str
|
|
6
|
-
.replace(/\(/g, '\\(')
|
|
7
|
-
.replace(/\)/g, '\\)');
|
|
8
|
-
async function spawnRead(filename, writes) {
|
|
9
|
-
const proc = spawn(process.execPath, [filename, 'child']);
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
let stdout = '';
|
|
12
|
-
let stderr = '';
|
|
13
|
-
proc.stdout.on('data', (c) => {
|
|
14
|
-
stdout += c;
|
|
15
|
-
for (const [prompt, write] of Object.entries(writes)) {
|
|
16
|
-
if (stdout.match(new RegExp(`${esc(prompt)} $`))) {
|
|
17
|
-
return process.nextTick(() => proc.stdin.write(`${write}\n`));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
reject(new Error(`unknown prompt:\n${stdout}\n${JSON.stringify(writes)}`));
|
|
21
|
-
});
|
|
22
|
-
proc.stderr.on('data', (c) => {
|
|
23
|
-
stderr += c;
|
|
24
|
-
});
|
|
25
|
-
proc.on('close', () => resolve({
|
|
26
|
-
stdout,
|
|
27
|
-
stderr,
|
|
28
|
-
}));
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
exports.spawnRead = spawnRead;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.spawnRead = spawnRead;
|
|
4
|
+
const spawn = require('child_process').spawn;
|
|
5
|
+
const esc = (str) => str
|
|
6
|
+
.replace(/\(/g, '\\(')
|
|
7
|
+
.replace(/\)/g, '\\)');
|
|
8
|
+
async function spawnRead(filename, writes) {
|
|
9
|
+
const proc = spawn(process.execPath, [filename, 'child']);
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
let stdout = '';
|
|
12
|
+
let stderr = '';
|
|
13
|
+
proc.stdout.on('data', (c) => {
|
|
14
|
+
stdout += c;
|
|
15
|
+
for (const [prompt, write] of Object.entries(writes)) {
|
|
16
|
+
if (stdout.match(new RegExp(`${esc(prompt)} $`))) {
|
|
17
|
+
return process.nextTick(() => proc.stdin.write(`${write}\n`));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
reject(new Error(`unknown prompt:\n${stdout}\n${JSON.stringify(writes)}`));
|
|
21
|
+
});
|
|
22
|
+
proc.stderr.on('data', (c) => {
|
|
23
|
+
stderr += c;
|
|
24
|
+
});
|
|
25
|
+
proc.on('close', () => resolve({
|
|
26
|
+
stdout,
|
|
27
|
+
stderr,
|
|
28
|
+
}));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
32
31
|
//# sourceMappingURL=fixtures.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../src/read/fixtures.ts"],"names":[],"mappings":"
|
|
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IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;YAC3B,MAAM,IAAI,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC;YAC7B,MAAM;YACN,MAAM;SACP,CAAC,CAAC,CAAA;IACL,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/read/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './read';
|
|
1
|
+
export * from './read';
|
package/dist/read/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./read"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./read"), exports);
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
package/dist/read/many.test.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/dist/read/many.test.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const chai_1 = require("chai");
|
|
4
|
-
const razmin_1 = require("razmin");
|
|
5
|
-
const fixtures_1 = require("./fixtures");
|
|
6
|
-
const read_1 = require("./read");
|
|
7
|
-
const times = new Array(18).fill(null).map((_, i) => (i + 1).toString());
|
|
8
|
-
if (process.argv[2] === 'child') {
|
|
9
|
-
child();
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
(0, razmin_1.describe)('read', it => {
|
|
13
|
-
it('many reads', async () => {
|
|
14
|
-
const writes = times.reduce((acc, k) => {
|
|
15
|
-
acc[`num ${k}`] = k;
|
|
16
|
-
return acc;
|
|
17
|
-
}, {});
|
|
18
|
-
const { stdout, stderr } = await (0, fixtures_1.spawnRead)(__filename, writes);
|
|
19
|
-
(0, chai_1.expect)(stdout).to.equal(Object.keys(writes).join(' ') + ' ');
|
|
20
|
-
(0, chai_1.expect)(stderr).to.equal(times.join(' ') + '\n');
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
async function child() {
|
|
25
|
-
const res = [];
|
|
26
|
-
for (const t of times) {
|
|
27
|
-
const r = await (0, read_1.read)({ prompt: `num ${t}` });
|
|
28
|
-
res.push(r);
|
|
29
|
-
}
|
|
30
|
-
console.error(...res);
|
|
31
|
-
if (process.stdin.unref) {
|
|
32
|
-
process.stdin.unref();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const razmin_1 = require("razmin");
|
|
5
|
+
const fixtures_1 = require("./fixtures");
|
|
6
|
+
const read_1 = require("./read");
|
|
7
|
+
const times = new Array(18).fill(null).map((_, i) => (i + 1).toString());
|
|
8
|
+
if (process.argv[2] === 'child') {
|
|
9
|
+
child();
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
(0, razmin_1.describe)('read', it => {
|
|
13
|
+
it('many reads', async () => {
|
|
14
|
+
const writes = times.reduce((acc, k) => {
|
|
15
|
+
acc[`num ${k}`] = k;
|
|
16
|
+
return acc;
|
|
17
|
+
}, {});
|
|
18
|
+
const { stdout, stderr } = await (0, fixtures_1.spawnRead)(__filename, writes);
|
|
19
|
+
(0, chai_1.expect)(stdout).to.equal(Object.keys(writes).join(' ') + ' ');
|
|
20
|
+
(0, chai_1.expect)(stderr).to.equal(times.join(' ') + '\n');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async function child() {
|
|
25
|
+
const res = [];
|
|
26
|
+
for (const t of times) {
|
|
27
|
+
const r = await (0, read_1.read)({ prompt: `num ${t}` });
|
|
28
|
+
res.push(r);
|
|
29
|
+
}
|
|
30
|
+
console.error(...res);
|
|
31
|
+
if (process.stdin.unref) {
|
|
32
|
+
process.stdin.unref();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
35
|
//# sourceMappingURL=many.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"many.test.js","sourceRoot":"","sources":["../../src/read/many.test.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,mCAAkC;AAClC,yCAAuC;AACvC,iCAA8B;AAE9B,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;AAExE,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"many.test.js","sourceRoot":"","sources":["../../src/read/many.test.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,mCAAkC;AAClC,yCAAuC;AACvC,iCAA8B;AAE9B,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;AAExE,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC;IAChC,KAAK,EAAE,CAAC;AACV,CAAC;KAAM,CAAC;IACN,IAAA,iBAAQ,EAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACpB,EAAE,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;YAC1B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;gBACrC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;gBACnB,OAAO,GAAG,CAAA;YACZ,CAAC,EAAE,EAAE,CAAC,CAAA;YACN,MAAM,EAAE,M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|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export declare function read(options?: ReadOptions): Promise<string>;
|
|
1
|
+
import { ReadStream, WriteStream } from 'tty';
|
|
2
|
+
export interface ReadOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The default value if the user enters nothing.
|
|
5
|
+
*/
|
|
6
|
+
default?: any;
|
|
7
|
+
/**
|
|
8
|
+
* Readable stream to get input data from. (default `process.stdin`)
|
|
9
|
+
*/
|
|
10
|
+
input?: ReadStream;
|
|
11
|
+
/**
|
|
12
|
+
* Writable stream to write prompts to. (default: `process.stdout`)
|
|
13
|
+
*/
|
|
14
|
+
output?: WriteStream;
|
|
15
|
+
/**
|
|
16
|
+
* What to write to stdout before reading input.
|
|
17
|
+
*/
|
|
18
|
+
prompt?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Don't echo the output as the user types it.
|
|
21
|
+
*/
|
|
22
|
+
silent?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Number of ms to wait for user input before giving up.
|
|
25
|
+
*/
|
|
26
|
+
timeout?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Allow the user to edit the default value.
|
|
29
|
+
*/
|
|
30
|
+
edit?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Treat the output as a TTY, whether it is or not.
|
|
33
|
+
*/
|
|
34
|
+
terminal?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Replace silenced characters with the supplied character value.
|
|
37
|
+
*/
|
|
38
|
+
replace?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare function read(options?: ReadOptions): Promise<string>;
|
package/dist/read/read.js
CHANGED
|
@@ -1,76 +1,75 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.read =
|
|
7
|
-
const readline_1 = __importDefault(require("readline"));
|
|
8
|
-
const mute_stream_1 = __importDefault(require("mute-stream"));
|
|
9
|
-
async function read(options) {
|
|
10
|
-
var _a, _b;
|
|
11
|
-
let opts = { prompt: '', ...options };
|
|
12
|
-
(_a = opts.input) !== null && _a !== void 0 ? _a : (opts.input = process.stdin);
|
|
13
|
-
(_b = opts.output) !== null && _b !== void 0 ? _b : (opts.output = process.stdout);
|
|
14
|
-
if (typeof opts.default !== 'undefined' && typeof opts.default !== 'string' && typeof opts.default !== 'number') {
|
|
15
|
-
throw new Error('default value must be string or number');
|
|
16
|
-
}
|
|
17
|
-
let editDef = false;
|
|
18
|
-
opts.prompt = opts.prompt.trim() + ' ';
|
|
19
|
-
opts.terminal = !!(opts.terminal || opts.output.isTTY);
|
|
20
|
-
if (opts.default) {
|
|
21
|
-
if (opts.silent) {
|
|
22
|
-
opts.prompt += '(<default hidden>) ';
|
|
23
|
-
}
|
|
24
|
-
else if (opts.edit) {
|
|
25
|
-
editDef = true;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
opts.prompt += '(' + opts.default + ') ';
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const input = opts.input;
|
|
32
|
-
const output = new mute_stream_1.default({ replace: opts.replace, prompt: opts.prompt });
|
|
33
|
-
output.pipe(opts.output, { end: false });
|
|
34
|
-
return new Promise((resolve, reject) => {
|
|
35
|
-
const rl = readline_1.default.createInterface({ input, output, terminal: opts.terminal });
|
|
36
|
-
const timer = opts.timeout && setTimeout(() => onError(new Error('timed out')), opts.timeout);
|
|
37
|
-
output.unmute();
|
|
38
|
-
rl.setPrompt(opts.prompt);
|
|
39
|
-
rl.prompt();
|
|
40
|
-
if (opts.silent) {
|
|
41
|
-
output.mute();
|
|
42
|
-
}
|
|
43
|
-
else if (editDef) {
|
|
44
|
-
rl.line = opts.default;
|
|
45
|
-
rl.cursor = opts.default.length;
|
|
46
|
-
rl._refreshLine();
|
|
47
|
-
}
|
|
48
|
-
const done = () => {
|
|
49
|
-
rl.close();
|
|
50
|
-
clearTimeout(timer);
|
|
51
|
-
output.mute();
|
|
52
|
-
output.end();
|
|
53
|
-
};
|
|
54
|
-
const onError = (er) => {
|
|
55
|
-
done();
|
|
56
|
-
reject(er);
|
|
57
|
-
};
|
|
58
|
-
rl.on('error', onError);
|
|
59
|
-
rl.on('line', (line) => {
|
|
60
|
-
if (opts.silent && opts.terminal) {
|
|
61
|
-
output.unmute();
|
|
62
|
-
output.write('\r\n');
|
|
63
|
-
}
|
|
64
|
-
done();
|
|
65
|
-
// truncate the \n at the end.
|
|
66
|
-
const res = line.replace(/\r?\n$/, '') || opts.default || '';
|
|
67
|
-
return resolve(res);
|
|
68
|
-
});
|
|
69
|
-
rl.on('SIGINT', () => {
|
|
70
|
-
rl.close();
|
|
71
|
-
onError(new Error('canceled'));
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
exports.read = read;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.read = read;
|
|
7
|
+
const readline_1 = __importDefault(require("readline"));
|
|
8
|
+
const mute_stream_1 = __importDefault(require("mute-stream"));
|
|
9
|
+
async function read(options) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
let opts = { prompt: '', ...options };
|
|
12
|
+
(_a = opts.input) !== null && _a !== void 0 ? _a : (opts.input = process.stdin);
|
|
13
|
+
(_b = opts.output) !== null && _b !== void 0 ? _b : (opts.output = process.stdout);
|
|
14
|
+
if (typeof opts.default !== 'undefined' && typeof opts.default !== 'string' && typeof opts.default !== 'number') {
|
|
15
|
+
throw new Error('default value must be string or number');
|
|
16
|
+
}
|
|
17
|
+
let editDef = false;
|
|
18
|
+
opts.prompt = opts.prompt.trim() + ' ';
|
|
19
|
+
opts.terminal = !!(opts.terminal || opts.output.isTTY);
|
|
20
|
+
if (opts.default) {
|
|
21
|
+
if (opts.silent) {
|
|
22
|
+
opts.prompt += '(<default hidden>) ';
|
|
23
|
+
}
|
|
24
|
+
else if (opts.edit) {
|
|
25
|
+
editDef = true;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
opts.prompt += '(' + opts.default + ') ';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const input = opts.input;
|
|
32
|
+
const output = new mute_stream_1.default({ replace: opts.replace, prompt: opts.prompt });
|
|
33
|
+
output.pipe(opts.output, { end: false });
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
const rl = readline_1.default.createInterface({ input, output, terminal: opts.terminal });
|
|
36
|
+
const timer = opts.timeout && setTimeout(() => onError(new Error('timed out')), opts.timeout);
|
|
37
|
+
output.unmute();
|
|
38
|
+
rl.setPrompt(opts.prompt);
|
|
39
|
+
rl.prompt();
|
|
40
|
+
if (opts.silent) {
|
|
41
|
+
output.mute();
|
|
42
|
+
}
|
|
43
|
+
else if (editDef) {
|
|
44
|
+
rl.line = opts.default;
|
|
45
|
+
rl.cursor = opts.default.length;
|
|
46
|
+
rl._refreshLine();
|
|
47
|
+
}
|
|
48
|
+
const done = () => {
|
|
49
|
+
rl.close();
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
output.mute();
|
|
52
|
+
output.end();
|
|
53
|
+
};
|
|
54
|
+
const onError = (er) => {
|
|
55
|
+
done();
|
|
56
|
+
reject(er);
|
|
57
|
+
};
|
|
58
|
+
rl.on('error', onError);
|
|
59
|
+
rl.on('line', (line) => {
|
|
60
|
+
if (opts.silent && opts.terminal) {
|
|
61
|
+
output.unmute();
|
|
62
|
+
output.write('\r\n');
|
|
63
|
+
}
|
|
64
|
+
done();
|
|
65
|
+
// truncate the \n at the end.
|
|
66
|
+
const res = line.replace(/\r?\n$/, '') || opts.default || '';
|
|
67
|
+
return resolve(res);
|
|
68
|
+
});
|
|
69
|
+
rl.on('SIGINT', () => {
|
|
70
|
+
rl.close();
|
|
71
|
+
onError(new Error('canceled'));
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
76
75
|
//# sourceMappingURL=read.js.map
|