13
13
// limitations under the License.
14
14
15
15
import assert from 'node:assert'
16
- import { test , describe , beforeEach , before , after } from 'node:test'
16
+ import { test , describe , after , before } from 'node:test'
17
17
import '../build/globals.js'
18
18
19
+ const __dirname = new URL ( '.' , import . meta. url ) . pathname
20
+ const root = path . resolve ( __dirname , '..' )
21
+
19
22
describe ( 'package' , ( ) => {
20
- before ( ( ) => syncProcessCwd ( ) )
21
- after ( ( ) => syncProcessCwd ( false ) )
22
- beforeEach ( async ( ) => {
23
+ before ( async ( ) => {
23
24
const pack = await $ `npm pack`
24
25
await $ `tar xf ${ pack } `
25
26
await $ `rm ${ pack } ` . nothrow ( )
26
27
} )
28
+ after ( async ( ) => {
29
+ await $ `rm -rf package`
30
+ } )
31
+
32
+ test ( 'content looks fine' , async ( ) => {
33
+ const files = await glob ( '**/*' , {
34
+ cwd : path . resolve ( root , 'package' ) ,
35
+ absolute : false ,
36
+ onlyFiles : true ,
37
+ } )
38
+ assert . deepEqual (
39
+ files . sort ( ) ,
40
+ [
41
+ 'LICENSE' ,
42
+ 'README.md' ,
43
+ 'package.json' ,
44
+ 'man/zx.1' ,
45
+ 'build/cli.cjs' ,
46
+ 'build/cli.d.ts' ,
47
+ 'build/cli.js' ,
48
+ 'build/core.cjs' ,
49
+ 'build/core.d.ts' ,
50
+ 'build/core.js' ,
51
+ 'build/deno.js' ,
52
+ 'build/deps.cjs' ,
53
+ 'build/deps.d.ts' ,
54
+ 'build/deps.js' ,
55
+ 'build/esblib.cjs' ,
56
+ 'build/globals.cjs' ,
57
+ 'build/globals.d.ts' ,
58
+ 'build/globals.js' ,
59
+ 'build/goods.cjs' ,
60
+ 'build/goods.d.ts' ,
61
+ 'build/goods.js' ,
62
+ 'build/index.cjs' ,
63
+ 'build/index.d.ts' ,
64
+ 'build/index.js' ,
65
+ 'build/repl.cjs' ,
66
+ 'build/repl.d.ts' ,
67
+ 'build/repl.js' ,
68
+ 'build/util.cjs' ,
69
+ 'build/util.d.ts' ,
70
+ 'build/util.js' ,
71
+ 'build/vendor-core.cjs' ,
72
+ 'build/vendor-core.d.ts' ,
73
+ 'build/vendor-core.js' ,
74
+ 'build/vendor-extra.cjs' ,
75
+ 'build/vendor-extra.d.ts' ,
76
+ 'build/vendor-extra.js' ,
77
+ 'build/vendor.cjs' ,
78
+ 'build/vendor.d.ts' ,
79
+ 'build/vendor.js' ,
80
+ ] . sort ( )
81
+ )
82
+ } )
27
83
28
84
test ( 'ts project' , async ( ) => {
29
- const pack = path . resolve ( 'package' )
30
85
const out = await within ( async ( ) => {
31
- cd ( 'test/ fixtures/ts-project')
86
+ $ . cwd = path . resolve ( __dirname , ' fixtures/ts-project')
32
87
await $ `npm i --no-package-lock`
33
88
try {
34
89
await $ `npx tsc`
@@ -41,9 +96,8 @@ describe('package', () => {
41
96
} )
42
97
43
98
test ( 'js project with zx' , async ( ) => {
44
- const pack = path . resolve ( 'package' )
45
99
const out = await within ( async ( ) => {
46
- cd ( 'test/ fixtures/js-project')
100
+ $ . cwd = path . resolve ( __dirname , ' fixtures/js-project')
47
101
await $ `npm i --no-package-lock`
48
102
return $ `node node_modules/zx/build/cli.js --verbose script.js`
49
103
} )
0 commit comments