@vanillaes/esmtk 0.22.0 → 0.22.1

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.
@@ -146,19 +146,7 @@
146
146
  "console": "integratedTerminal",
147
147
  },
148
148
  {
149
- "name": "CopyFileToFolder",
150
- "type": "node",
151
- "request": "launch",
152
- "skipFiles": [
153
- "<node_internals>/**"
154
- ],
155
- "program": "${workspaceFolder}/bin/esmtk.js",
156
- "cwd": "${workspaceFolder}",
157
- "args": ["cp", "./test/cp/test1.txt", "./test/cp2/test1.txt"],
158
- "console": "integratedTerminal",
159
- },
160
- {
161
- "name": "CopyGlobToFolder",
149
+ "name": "CopyFileToFile - Error source doesn't exist",
162
150
  "type": "node",
163
151
  "request": "launch",
164
152
  "skipFiles": [
@@ -166,11 +154,11 @@
166
154
  ],
167
155
  "program": "${workspaceFolder}/bin/esmtk.js",
168
156
  "cwd": "${workspaceFolder}",
169
- "args": ["cp", "./test/cp/*.js", "./test/cp2/"],
157
+ "args": ["cp", "./test/cp/testx.txt", "./test/cp2/"],
170
158
  "console": "integratedTerminal",
171
159
  },
172
160
  {
173
- "name": "CopyFileToFile - Error source doesn't exist",
161
+ "name": "CopyFileToFile - Error source is a directory",
174
162
  "type": "node",
175
163
  "request": "launch",
176
164
  "skipFiles": [
@@ -178,11 +166,11 @@
178
166
  ],
179
167
  "program": "${workspaceFolder}/bin/esmtk.js",
180
168
  "cwd": "${workspaceFolder}",
181
- "args": ["cp", "./test/cp/testx.txt", "./test/cp2/"],
169
+ "args": ["cp", "./test/cp/", "./test/cp2/test1.txt"],
182
170
  "console": "integratedTerminal",
183
171
  },
184
172
  {
185
- "name": "CopyFileToFile - Error source is a directory",
173
+ "name": "CopyFileToFile - Error target directory doesn't exist",
186
174
  "type": "node",
187
175
  "request": "launch",
188
176
  "skipFiles": [
@@ -190,11 +178,11 @@
190
178
  ],
191
179
  "program": "${workspaceFolder}/bin/esmtk.js",
192
180
  "cwd": "${workspaceFolder}",
193
- "args": ["cp", "./test/cp/", "./test/cp2/test1.txt"],
181
+ "args": ["cp", "./test/cp/test1.txt", "./test/cpx/"],
194
182
  "console": "integratedTerminal",
195
183
  },
196
184
  {
197
- "name": "CopyFileToFile - Error target directory doesn't exist",
185
+ "name": "CopyFileToDirectory",
198
186
  "type": "node",
199
187
  "request": "launch",
200
188
  "skipFiles": [
@@ -202,11 +190,11 @@
202
190
  ],
203
191
  "program": "${workspaceFolder}/bin/esmtk.js",
204
192
  "cwd": "${workspaceFolder}",
205
- "args": ["cp", "./test/cp/test1.txt", "./test/cpx/"],
193
+ "args": ["cp", "./test/cp/test1.txt", "./test/cp2/test1.txt"],
206
194
  "console": "integratedTerminal",
207
195
  },
208
196
  {
209
- "name": "CopyFolderRecursively",
197
+ "name": "CopyGlobToDirectory",
210
198
  "type": "node",
211
199
  "request": "launch",
212
200
  "skipFiles": [
@@ -214,7 +202,7 @@
214
202
  ],
215
203
  "program": "${workspaceFolder}/bin/esmtk.js",
216
204
  "cwd": "${workspaceFolder}",
217
- "args": ["cp", "-r", "./test/cp/", "./test/cp2"],
205
+ "args": ["cp", "./test/cp/*.js", "./test/cp2/"],
218
206
  "console": "integratedTerminal",
219
207
  },
220
208
  {
@@ -277,6 +265,18 @@
277
265
  "args": ["cp", "./test/cp/test1.txt", "./test/cp/test2.txt", "./test/cp/*.js", "./test/cp2/"],
278
266
  "console": "integratedTerminal",
279
267
  },
268
+ {
269
+ "name": "CopyDirectoryRecursively",
270
+ "type": "node",
271
+ "request": "launch",
272
+ "skipFiles": [
273
+ "<node_internals>/**"
274
+ ],
275
+ "program": "${workspaceFolder}/bin/esmtk.js",
276
+ "cwd": "${workspaceFolder}",
277
+ "args": ["cp", "-r", "./test/cp/", "./test/cp2"],
278
+ "console": "integratedTerminal",
279
+ },
280
280
  {
281
281
  "name": "RemoveFile",
282
282
  "type": "node",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vanillaes/esmtk",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "description": "ES Module Toolkit",
5
5
  "keywords": [
6
6
  "ecmascript",
@@ -0,0 +1,68 @@
1
+ {
2
+ "copyAsync": {
3
+ "cp1": {
4
+ "test1.txt": "test 1 text",
5
+ "test2.txt": "test 2 text"
6
+ },
7
+ "cp2": {}
8
+ },
9
+ "copyAsyncExpect": {
10
+ "cp1": {
11
+ "test1.txt": "test 1 text",
12
+ "test2.txt": "test 2 text"
13
+ },
14
+ "cp2": {
15
+ "test1.txt": "test 1 text"
16
+ }
17
+ },
18
+ "copyMultipleAsync": {
19
+ "cp1": {
20
+ "test1.txt": "test 1 text",
21
+ "test2.txt": "test 2 text",
22
+ "test1.js": "test 1 javascript",
23
+ "test2.js": "test 2 javascript"
24
+ },
25
+ "cp2": {}
26
+ },
27
+ "copyMultipleAsyncExpect": {
28
+ "cp1": {
29
+ "test1.txt": "test 1 text",
30
+ "test2.txt": "test 2 text",
31
+ "test1.js": "test 1 javascript",
32
+ "test2.js": "test 2 javascript"
33
+ },
34
+ "cp2": {
35
+ "test1.txt": "test 1 text",
36
+ "test1.js": "test 1 javascript"
37
+ }
38
+ },
39
+ "copyRecursiveAsync": {
40
+ "cp1": {
41
+ "test1.txt": "test 1 text",
42
+ "test1.js": "test 1 javascript",
43
+ "sub": {
44
+ "test2.txt": "test 2 text",
45
+ "test2.js": "test 2 javascript"
46
+ }
47
+ },
48
+ "cp2": {}
49
+ },
50
+ "copyRecursiveAsyncExpect": {
51
+ "cp1": {
52
+ "test1.txt": "test 1 text",
53
+ "test1.js": "test 1 javascript",
54
+ "sub": {
55
+ "test2.txt": "test 2 text",
56
+ "test2.js": "test 2 javascript"
57
+ }
58
+ },
59
+ "cp2": {
60
+ "test1.txt": "test 1 text",
61
+ "test1.js": "test 1 javascript",
62
+ "sub": {
63
+ "test2.txt": "test 2 text",
64
+ "test2.js": "test 2 javascript"
65
+ }
66
+ }
67
+ }
68
+ }
package/src/cp.spec.js ADDED
@@ -0,0 +1,106 @@
1
+ import { filesλobjects, setup, teardown, test } from './__test__/test.js'
2
+ import { copyAsync, copyMultipleAsync, copyRecursiveAsync } from '@vanillaes/esmtk'
3
+ import { rmSync } from 'node:fs'
4
+
5
+ import { createRequire } from 'module'
6
+ const require = createRequire(import.meta.url)
7
+ const files = require('./__test__/cp.json')
8
+ const processExit = process.exit
9
+
10
+ setup(async (t) => {
11
+ process.exit = function () {
12
+ throw new Error('process.exit(1)')
13
+ }
14
+ process.chdir(process.cwd())
15
+ rmSync('test', { recursive: true, force: true })
16
+
17
+ t.end()
18
+ })
19
+
20
+ test('copyAsync - copy file-to-file', files.copyAsync, async (t) => {
21
+ await copyAsync('cp1/test1.txt', 'cp2/test1.txt')
22
+
23
+ const actual = filesλobjects()
24
+ const expect = files.copyAsyncExpect
25
+
26
+ t.deepEqual(actual, expect)
27
+ t.end()
28
+ })
29
+
30
+ test('copyAsync - copy file-to-file - ERROR: no such file or directory (source)', files.copyAsync, async (t) => {
31
+ try {
32
+ await copyAsync('cp1/test1.ts', 'cp2/test1.ts')
33
+ t.fail('Expected error was not thrown')
34
+ } catch (err) {
35
+ t.ok(err, 'Error was thrown as expected')
36
+ }
37
+ t.end()
38
+ })
39
+
40
+ test('copyAsync - copy file-to-file - ERROR: source is a directory', files.copyAsync, async (t) => {
41
+ try {
42
+ await copyAsync('cp1/', 'cp2/test1.txt')
43
+ t.fail('Expected error was not thrown')
44
+ } catch (err) {
45
+ t.ok(err, 'Error was thrown as expected')
46
+ }
47
+ t.end()
48
+ })
49
+
50
+ test('copyAsync - copy file-to-directory', files.copyAsync, async (t) => {
51
+ await copyAsync('cp1/test1.txt', 'cp2/')
52
+
53
+ const actual = filesλobjects()
54
+ const expect = files.copyAsyncExpect
55
+
56
+ t.deepEqual(actual, expect)
57
+ t.end()
58
+ })
59
+
60
+ test('copyAsync - copy file-to-directory - ERROR: no such file or directory (target)', files.copyAsync, async (t) => {
61
+ try {
62
+ await copyAsync('cp1/test1.txt', 'cpx/')
63
+ t.fail('Expected error was not thrown')
64
+ } catch (err) {
65
+ t.ok(err, 'Error was thrown as expected')
66
+ }
67
+ t.end()
68
+ })
69
+
70
+ test('copyMultipleAsync - copy multiple files', files.copyMultipleAsync, async (t) => {
71
+ await copyMultipleAsync(['cp1/test1.txt', 'cp1/test1.js'], 'cp2/')
72
+
73
+ const actual = filesλobjects()
74
+ const expect = files.copyMultipleAsyncExpect
75
+
76
+ t.deepEqual(actual, expect)
77
+ t.end()
78
+ })
79
+
80
+ test('copyMultipleAsync - copy multiple files - ERROR: no such file or directory (target)', files.copyMultipleAsync, async (t) => {
81
+ try {
82
+ await copyMultipleAsync(['cp1/test1.txt', 'cp1/test1.js'], 'cpx/')
83
+ t.fail('Expected error was not thrown')
84
+ } catch (err) {
85
+ t.ok(err, 'Error was thrown as expected')
86
+ }
87
+ t.end()
88
+ })
89
+
90
+ test('copyRecursiveAsync - ', files.copyRecursiveAsync, async (t) => {
91
+ await copyRecursiveAsync('cp1/', 'cp2/')
92
+
93
+ const actual = filesλobjects()
94
+ const expect = files.copyRecursiveAsyncExpect
95
+
96
+ t.deepEqual(actual, expect)
97
+ t.end()
98
+ })
99
+
100
+ teardown(async (t) => {
101
+ process.exit = processExit
102
+ process.chdir(process.cwd())
103
+ rmSync('test', { recursive: true, force: true })
104
+
105
+ t.end()
106
+ })
package/src/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { copyAsync, copyRecursiveAsync } from './cp.js'
1
+ export { copyAsync, copyMultipleAsync, copyRecursiveAsync } from './cp.js'
2
2
  export { removeAsync, removeMultipleAsync, removeRecursiveAsync } from './rm.js'
3
3
  export { expand, fileExists, installed, match, which } from './util.js'
package/src/rm.spec.js CHANGED
@@ -30,6 +30,7 @@ test('removeAsync - remove a file', files.removeAsync, async (t) => {
30
30
  test('removeAsync - ERROR: no such file or directory', files.removeAsync, async (t) => {
31
31
  try {
32
32
  await removeAsync('test1.ts')
33
+ t.fail('Expected error was not thrown')
33
34
  } catch (err) {
34
35
  t.ok(err, 'Error was thrown as expected')
35
36
  }