Repository navigation
Expand file tree
/
Copy pathreplace.js
More file actions
70 lines (58 loc) Β· 1.85 KB
/
Copy pathreplace.js
File metadata and controls
70 lines (58 loc) Β· 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import test from 'supertape';
import replace from '../lib/replace.js';
test('replace: one npm run ', async (t) => {
const result = await replace('npm run one', (type, str) => {
t.equal(type, 'npm', 'type should be npm');
return str;
});
t.equal(result, 'one', 'should get script name');
t.end();
}, {
checkAssertionsCount: false,
});
test('replace: npm tst', async (t) => {
const result = await replace('npm tst', (type, str) => {
t.equal(type, 'npm', 'type should be npm');
return str;
});
t.equal(result, 'test', 'should determine reserved: tst');
t.end();
}, {
checkAssertionsCount: false,
});
test('replace: npm t', async (t) => {
const result = await replace('npm t', (type, str) => {
t.equal(type, 'npm', 'type should be npm');
return str;
});
t.equal(result, 'test', 'should determine reserved: t');
t.end();
}, {
checkAssertionsCount: false,
});
test('replace: npm version', async (t) => {
const result = await replace('npm version', (type, str) => {
t.equal(type, 'npm', 'type should be npm');
return str;
});
t.equal(result, 'npm version', 'should leave unchanged "npm version"');
t.end();
});
test('replace: npm publish', async (t) => {
const result = await replace('npm publish', (type, str) => {
t.equal(type, 'npm', 'type should be npm');
return str;
});
t.equal(result, 'npm publish', 'should leave unchanged "npm publish"');
t.end();
});
test('replace: a few npm runs', async (t) => {
const cmd = await replace('npm run one && npm run two', (type, str) => {
t.equal(type, 'npm', 'type should be npm');
return str;
});
t.equal(cmd, 'one && two', 'should cut npm run from all expressions');
t.end();
}, {
checkAssertionsCount: false,
});