sxy-test-runner 1.4.4 → 2.0.0
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/cli/index.js +24 -22
- package/dist/cli/init.js +41 -91
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/lib/addBasePath.d.ts.map +1 -1
- package/dist/cli/lib/addBasePath.js +12 -14
- package/dist/cli/lib/addBasePath.js.map +1 -1
- package/dist/cli/lib/addBasePath.unitTest.d.ts +2 -0
- package/dist/cli/lib/addBasePath.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/addBasePath.unitTest.js +51 -29
- package/dist/cli/lib/addBasePath.unitTest.js.map +1 -0
- package/dist/cli/lib/addExports.js +13 -11
- package/dist/cli/lib/addExports.unitTest.d.ts +2 -0
- package/dist/cli/lib/addExports.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/addExports.unitTest.js +15 -30
- package/dist/cli/lib/addExports.unitTest.js.map +1 -0
- package/dist/cli/lib/applyConfigDefaults.js +6 -42
- package/dist/cli/lib/applyConfigDefaults.js.map +1 -1
- package/dist/cli/lib/applyConfigDefaults.unitTest.d.ts +2 -0
- package/dist/cli/lib/applyConfigDefaults.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/applyConfigDefaults.unitTest.js +19 -27
- package/dist/cli/lib/applyConfigDefaults.unitTest.js.map +1 -0
- package/dist/cli/lib/buildDependencyTree.js +23 -34
- package/dist/cli/lib/buildDependencyTree.js.map +1 -1
- package/dist/cli/lib/buildDependencyTree.unitTest.d.ts +2 -0
- package/dist/cli/lib/buildDependencyTree.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/buildDependencyTree.unitTest.js +13 -11
- package/dist/cli/lib/buildDependencyTree.unitTest.js.map +1 -0
- package/dist/cli/lib/buildDependencyTrees.js +15 -34
- package/dist/cli/lib/buildDependencyTrees.js.map +1 -1
- package/dist/cli/lib/buildDependencyTrees.unitTest.d.ts +2 -0
- package/dist/cli/lib/buildDependencyTrees.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/buildDependencyTrees.unitTest.js +18 -14
- package/dist/cli/lib/buildDependencyTrees.unitTest.js.map +1 -0
- package/dist/cli/lib/defaultConfig.js +23 -21
- package/dist/cli/lib/defaultConfig.unitTest.d.ts +2 -0
- package/dist/cli/lib/defaultConfig.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/defaultConfig.unitTest.js +7 -0
- package/dist/cli/lib/defaultConfig.unitTest.js.map +1 -0
- package/dist/cli/lib/doUserSetup.d.ts +1 -1
- package/dist/cli/lib/doUserSetup.d.ts.map +1 -1
- package/dist/cli/lib/doUserSetup.js +20 -23
- package/dist/cli/lib/doUserSetup.js.map +1 -1
- package/dist/cli/lib/doUserSetup.unitTest.d.ts +7 -0
- package/dist/cli/lib/doUserSetup.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/doUserSetup.unitTest.js +41 -36
- package/dist/cli/lib/doUserSetup.unitTest.js.map +1 -0
- package/dist/cli/lib/doUserTeardown.d.ts +1 -1
- package/dist/cli/lib/doUserTeardown.d.ts.map +1 -1
- package/dist/cli/lib/doUserTeardown.js +21 -23
- package/dist/cli/lib/doUserTeardown.js.map +1 -1
- package/dist/cli/lib/doUserTeardown.unitTest.d.ts +7 -0
- package/dist/cli/lib/doUserTeardown.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/doUserTeardown.unitTest.js +41 -36
- package/dist/cli/lib/doUserTeardown.unitTest.js.map +1 -0
- package/dist/cli/lib/findTestFiles.d.ts.map +1 -1
- package/dist/cli/lib/findTestFiles.js +16 -24
- package/dist/cli/lib/findTestFiles.js.map +1 -1
- package/dist/cli/lib/findTestFiles.unitTest.d.ts +2 -0
- package/dist/cli/lib/findTestFiles.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/findTestFiles.unitTest.js +19 -19
- package/dist/cli/lib/findTestFiles.unitTest.js.map +1 -0
- package/dist/cli/lib/getAllowedFlags.js +10 -8
- package/dist/cli/lib/getAllowedFlags.unitTest.d.ts +2 -0
- package/dist/cli/lib/getAllowedFlags.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/getAllowedFlags.unitTest.js +22 -21
- package/dist/cli/lib/getAllowedFlags.unitTest.js.map +1 -0
- package/dist/cli/lib/globArgCombine.js +8 -1
- package/dist/cli/lib/globArgCombine.unitTest.d.ts +2 -0
- package/dist/cli/lib/globArgCombine.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/globArgCombine.unitTest.js +19 -18
- package/dist/cli/lib/globArgCombine.unitTest.js.map +1 -0
- package/dist/cli/lib/injectProperties.d.ts.map +1 -1
- package/dist/cli/lib/injectProperties.js +10 -10
- package/dist/cli/lib/injectProperties.js.map +1 -1
- package/dist/cli/lib/injectProperties.unitTest.d.ts +2 -0
- package/dist/cli/lib/injectProperties.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/injectProperties.unitTest.js +19 -81
- package/dist/cli/lib/injectProperties.unitTest.js.map +1 -0
- package/dist/cli/lib/loadConfig.js +14 -18
- package/dist/cli/lib/loadConfig.js.map +1 -1
- package/dist/cli/lib/loadConfig.unitTest.d.ts +2 -0
- package/dist/cli/lib/loadConfig.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/loadConfig.unitTest.js +15 -15
- package/dist/cli/lib/loadConfig.unitTest.js.map +1 -0
- package/dist/cli/lib/loadTestFile.js +48 -78
- package/dist/cli/lib/loadTestFile.js.map +1 -1
- package/dist/cli/lib/loadTestFile.unitTest.d.ts +2 -0
- package/dist/cli/lib/loadTestFile.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/loadTestFile.unitTest.js +12 -49
- package/dist/cli/lib/loadTestFile.unitTest.js.map +1 -0
- package/dist/cli/lib/parseCommandLineArguments.js +48 -42
- package/dist/cli/lib/parseCommandLineArguments.unitTest.d.ts +2 -0
- package/dist/cli/lib/parseCommandLineArguments.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/parseCommandLineArguments.unitTest.js +22 -24
- package/dist/cli/lib/parseCommandLineArguments.unitTest.js.map +1 -0
- package/dist/cli/lib/parseDescribe.d.ts.map +1 -1
- package/dist/cli/lib/parseDescribe.js +67 -81
- package/dist/cli/lib/parseDescribe.js.map +1 -1
- package/dist/cli/lib/parseDescribe.unitTest.d.ts +2 -0
- package/dist/cli/lib/parseDescribe.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/parseDescribe.unitTest.js +20 -18
- package/dist/cli/lib/parseDescribe.unitTest.js.map +1 -0
- package/dist/cli/lib/reservedExportKeys.d.ts +2 -0
- package/dist/cli/lib/reservedExportKeys.d.ts.map +1 -0
- package/dist/cli/lib/reservedExportKeys.js +12 -1
- package/dist/cli/lib/reservedExportKeys.js.map +1 -0
- package/dist/cli/lib/reservedExportKeys.unitTest.d.ts +2 -0
- package/dist/cli/lib/reservedExportKeys.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/reservedExportKeys.unitTest.js +6 -8
- package/dist/cli/lib/reservedExportKeys.unitTest.js.map +1 -0
- package/dist/cli/lib/runDescribe.d.ts.map +1 -1
- package/dist/cli/lib/runDescribe.js +39 -39
- package/dist/cli/lib/runDescribe.js.map +1 -1
- package/dist/cli/lib/runDescribe.unitTest.d.ts +2 -0
- package/dist/cli/lib/runDescribe.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/runDescribe.unitTest.js +22 -402
- package/dist/cli/lib/runDescribe.unitTest.js.map +1 -0
- package/dist/cli/lib/runDescribeRun.js +34 -49
- package/dist/cli/lib/runDescribeRun.js.map +1 -1
- package/dist/cli/lib/runDescribeRun.unitTest.d.ts +2 -0
- package/dist/cli/lib/runDescribeRun.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/runDescribeRun.unitTest.js +44 -410
- package/dist/cli/lib/runDescribeRun.unitTest.js.map +1 -0
- package/dist/cli/lib/runIt.d.ts +1 -1
- package/dist/cli/lib/runIt.d.ts.map +1 -1
- package/dist/cli/lib/runIt.js +59 -69
- package/dist/cli/lib/runIt.js.map +1 -1
- package/dist/cli/lib/runIt.unitTest.d.ts +2 -0
- package/dist/cli/lib/runIt.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/runIt.unitTest.js +73 -410
- package/dist/cli/lib/runIt.unitTest.js.map +1 -0
- package/dist/cli/lib/runTasks.d.ts +1 -1
- package/dist/cli/lib/runTasks.d.ts.map +1 -1
- package/dist/cli/lib/runTasks.js +28 -31
- package/dist/cli/lib/runTasks.js.map +1 -1
- package/dist/cli/lib/runTasks.unitTest.d.ts +5 -0
- package/dist/cli/lib/runTasks.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/runTasks.unitTest.js +35 -31
- package/dist/cli/lib/runTasks.unitTest.js.map +1 -0
- package/dist/cli/lib/runTest.js +54 -66
- package/dist/cli/lib/runTest.js.map +1 -1
- package/dist/cli/lib/runTest.unitTest.d.ts +20 -0
- package/dist/cli/lib/runTest.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/runTest.unitTest.js +274 -289
- package/dist/cli/lib/runTest.unitTest.js.map +1 -0
- package/dist/cli/lib/runTests.d.ts.map +1 -1
- package/dist/cli/lib/runTests.js +123 -141
- package/dist/cli/lib/runTests.js.map +1 -1
- package/dist/cli/lib/runTests.unitTest.d.ts +6 -0
- package/dist/cli/lib/runTests.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/runTests.unitTest.js +48 -61
- package/dist/cli/lib/runTests.unitTest.js.map +1 -0
- package/dist/cli/lib/showTestLoadingError.js +22 -33
- package/dist/cli/lib/showTestLoadingError.js.map +1 -1
- package/dist/cli/lib/showTestLoadingError.unitTest.d.ts +2 -0
- package/dist/cli/lib/showTestLoadingError.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/showTestLoadingError.unitTest.js +16 -24
- package/dist/cli/lib/showTestLoadingError.unitTest.js.map +1 -0
- package/dist/cli/lib/showTestResult.js +88 -88
- package/dist/cli/lib/showTestResult.js.map +1 -1
- package/dist/cli/lib/showTestResult.unitTest.d.ts +2 -0
- package/dist/cli/lib/showTestResult.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/showTestResult.unitTest.js +176 -184
- package/dist/cli/lib/showTestResult.unitTest.js.map +1 -0
- package/dist/cli/lib/testHelpers/makeCustomOut.d.ts +7 -0
- package/dist/cli/lib/testHelpers/makeCustomOut.d.ts.map +1 -0
- package/dist/cli/lib/testHelpers/makeCustomOut.js +10 -0
- package/dist/cli/lib/testHelpers/makeCustomOut.js.map +1 -0
- package/dist/cli/lib/timeProfier.js +4 -6
- package/dist/cli/lib/timeProfier.js.map +1 -1
- package/dist/cli/lib/validateConfig.js +21 -24
- package/dist/cli/lib/validateConfig.unitTest.d.ts +2 -0
- package/dist/cli/lib/validateConfig.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/validateConfig.unitTest.js +17 -18
- package/dist/cli/lib/validateConfig.unitTest.js.map +1 -0
- package/dist/cli/lib/{watchFiles.js → watchFiles.d.ts} +2 -1
- package/dist/cli/lib/watchFiles.d.ts.map +1 -0
- package/dist/cli/lib/watchFiles.js.map +1 -0
- package/dist/cli/lib/watchFiles.unitTest.d.ts +2 -0
- package/dist/cli/lib/watchFiles.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/watchFiles.unitTest.js.map +1 -0
- package/dist/cli/lib/watchFilesAndRunTests.js +2 -3
- package/dist/cli/lib/watchFilesAndRunTests.unitTest.d.ts +2 -0
- package/dist/cli/lib/watchFilesAndRunTests.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/watchFilesAndRunTests.unitTest.js +86 -96
- package/dist/cli/lib/watchFilesAndRunTests.unitTest.js.map +1 -0
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.d.ts.map +1 -1
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.js +99 -127
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.js.map +1 -1
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.d.ts +2 -0
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js +90 -99
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js.map +1 -0
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.d.ts.map +1 -1
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js +108 -148
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.js.map +1 -1
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.d.ts +2 -0
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js +87 -100
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js.map +1 -0
- package/dist/cli/lib/watchFilesChokidar.js +30 -56
- package/dist/cli/lib/watchFilesChokidar.js.map +1 -1
- package/dist/cli/lib/watchFilesChokidar.unitTest.d.ts +2 -0
- package/dist/cli/lib/watchFilesChokidar.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/watchFilesChokidar.unitTest.js +77 -81
- package/dist/cli/lib/watchFilesChokidar.unitTest.js.map +1 -0
- package/dist/cli/lib/watchFilesNodeWatch.js +31 -41
- package/dist/cli/lib/watchFilesNodeWatch.js.map +1 -1
- package/dist/cli/lib/watchFilesNodeWatch.unitTest.d.ts +2 -0
- package/dist/cli/lib/watchFilesNodeWatch.unitTest.d.ts.map +1 -0
- package/dist/cli/lib/watchFilesNodeWatch.unitTest.js +41 -46
- package/dist/cli/lib/watchFilesNodeWatch.unitTest.js.map +1 -0
- package/dist/cli/once.js +35 -42
- package/dist/cli/once.js.map +1 -1
- package/dist/cli/watch.js +64 -114
- package/dist/cli/watch.js.map +1 -1
- package/dist/cli/watch.unitTest.d.ts +6 -0
- package/dist/cli/watch.unitTest.d.ts.map +1 -0
- package/dist/cli/watch.unitTest.js +100 -111
- package/dist/cli/watch.unitTest.js.map +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +13 -2
- package/dist/config.js.map +1 -1
- package/dist/describe.js +20 -34
- package/dist/describe.js.map +1 -1
- package/dist/describe.unitTest.d.ts +2 -0
- package/dist/describe.unitTest.d.ts.map +1 -0
- package/dist/describe.unitTest.js +19 -23
- package/dist/describe.unitTest.js.map +1 -0
- package/dist/index.js +2 -1
- package/dist/indexNumberToLetters.js +12 -11
- package/dist/output.js +16 -18
- package/dist/packages/chalk.d.ts +14 -0
- package/dist/packages/chalk.d.ts.map +1 -0
- package/dist/packages/chalk.js +22 -0
- package/dist/packages/chalk.js.map +1 -0
- package/dist/packages/figures.d.ts +6 -0
- package/dist/packages/figures.d.ts.map +1 -0
- package/dist/packages/figures.js +24 -0
- package/dist/packages/figures.js.map +1 -0
- package/dist/packages/loadConfig.d.ts +3 -0
- package/dist/packages/loadConfig.d.ts.map +1 -0
- package/dist/packages/loadConfig.js +28 -0
- package/dist/packages/loadConfig.js.map +1 -0
- package/dist/packages/mergeStructuredConfig.d.ts +2 -0
- package/dist/packages/mergeStructuredConfig.d.ts.map +1 -0
- package/dist/packages/mergeStructuredConfig.js +26 -0
- package/dist/packages/mergeStructuredConfig.js.map +1 -0
- package/dist/packages/slash.d.ts +2 -0
- package/dist/packages/slash.d.ts.map +1 -0
- package/dist/packages/slash.js +9 -0
- package/dist/packages/slash.js.map +1 -0
- package/dist/packages/timeProfiler.d.ts +6 -0
- package/dist/packages/timeProfiler.d.ts.map +1 -0
- package/dist/packages/timeProfiler.js +32 -0
- package/dist/packages/timeProfiler.js.map +1 -0
- package/dist/types.d.ts +13 -13
- package/dist/types.d.ts.map +1 -1
- package/package.json +24 -20
- package/dist/cli/files.js +0 -20
- package/dist/cli/files.unitTest.js +0 -246
- package/dist/cli/init.unitTest.js +0 -0
- package/dist/cli/lib/defaultConfig.test.js +0 -9
- package/dist/cli/lib/loadTestFileStatic.js +0 -41
- package/dist/cli/lib/loadTestFileStatic.unitTest.js +0 -30
- package/dist/cli/lib/processWatchEvent.js +0 -1
- package/dist/cli/lib/processWatchEvent.unitTest.js +0 -15
- package/dist/cli/lib/runDescribe.old.js +0 -108
- package/dist/cli/lib/runDescribe.old.unitTest.js +0 -440
- package/dist/cli/lib/runTest-old.js +0 -160
- package/dist/cli/lib/runTest-old.unitTest.js +0 -184
- package/dist/cli/lib/watchFiles.unitTest.js +0 -50
- package/dist/cli/once.unitTest.js +0 -39
- package/dist/describe-old.js +0 -271
- package/dist/describe-old.unitTest.js +0 -30
- package/dist/exported.eslintrc.js +0 -7
- package/dist/lib/arrayRemove.d.ts +0 -2
- package/dist/lib/arrayRemove.d.ts.map +0 -1
- package/dist/lib/arrayRemove.js +0 -15
- package/dist/lib/arrayRemove.js.map +0 -1
- package/dist/lib/promiseAllObj.d.ts +0 -2
- package/dist/lib/promiseAllObj.d.ts.map +0 -1
- package/dist/lib/promiseAllObj.js +0 -14
- package/dist/lib/promiseAllObj.js.map +0 -1
- package/dist/testsState.js +0 -5
- package/dist/timeProfiling.js +0 -9
|
@@ -1,40 +1,30 @@
|
|
|
1
1
|
import { promises as fs, existsSync } from 'fs';
|
|
2
|
-
import figures from 'figures';
|
|
3
|
-
import { objectCopy } from 'sxy-lib-object-copy';
|
|
2
|
+
import figures from '../../packages/figures.js';
|
|
4
3
|
import { watchFilesAndRunTestsNodeWatch } from './watchFilesAndRunTestsNodeWatch.js';
|
|
5
4
|
import { applyConfigDefaults } from './applyConfigDefaults.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
watchFilesAndRunTestsNodeWatch(config, [], {}, [], customOut);
|
|
30
|
-
|
|
31
|
-
//console.log('outBuffer', outBuffer)
|
|
32
|
-
|
|
33
|
-
await outBuffer.should.equal('');
|
|
34
|
-
const testFileName = `${tempFolder}/a.test.js`;
|
|
35
|
-
const thing = 'Sample test 1';
|
|
36
|
-
const should = '1 should equal 1';
|
|
37
|
-
await fs.writeFile(testFileName, `import { describe } from '../../dist/index.js'
|
|
5
|
+
mochaDescribe('watchFilesAndRunTestsNodeWatch() function', function () {
|
|
6
|
+
const tempFolder = 'watchTests/watchFilesAndRunTestsNodeWatch';
|
|
7
|
+
const baseConfig = applyConfigDefaults({
|
|
8
|
+
testsBase: tempFolder,
|
|
9
|
+
tests: '**/*.test.js',
|
|
10
|
+
watch: {
|
|
11
|
+
watchFilesBase: tempFolder,
|
|
12
|
+
watchFiles: '**/*.js'
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
mochaIt('should run a test when a test file is changed', async function () {
|
|
16
|
+
const config = structuredClone(baseConfig);
|
|
17
|
+
// create a custom out function to capture the output
|
|
18
|
+
let outBuffer = '';
|
|
19
|
+
const customOut = (...texts) => {
|
|
20
|
+
outBuffer += texts.join(' ') + '\n';
|
|
21
|
+
};
|
|
22
|
+
void watchFilesAndRunTestsNodeWatch(config, [], {}, [], customOut);
|
|
23
|
+
outBuffer.should.equal('');
|
|
24
|
+
const testFileName = `${tempFolder}/a.test.js`;
|
|
25
|
+
const thing = 'Sample test 1';
|
|
26
|
+
const should = '1 should equal 1';
|
|
27
|
+
void fs.writeFile(testFileName, `import { describe } from '../../dist/index.js'
|
|
38
28
|
import { expect, should } from 'chai'
|
|
39
29
|
should()
|
|
40
30
|
|
|
@@ -45,31 +35,30 @@ describe('${thing}', ({it}) => {
|
|
|
45
35
|
})
|
|
46
36
|
|
|
47
37
|
})`);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
await fs.writeFile(testFileName, `import { describe } from '../../dist/index.js'
|
|
38
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
39
|
+
outBuffer.should.not.equal('');
|
|
40
|
+
outBuffer.should.include(testFileName);
|
|
41
|
+
outBuffer.should.include(thing);
|
|
42
|
+
outBuffer.should.include(should);
|
|
43
|
+
outBuffer.should.include(figures.tick);
|
|
44
|
+
});
|
|
45
|
+
mochaIt('should run a test when a new test file is changed', async function () {
|
|
46
|
+
const config = structuredClone(baseConfig);
|
|
47
|
+
// create a custom out function to capture the output
|
|
48
|
+
let outBuffer = '';
|
|
49
|
+
const customOut = (...texts) => {
|
|
50
|
+
outBuffer += texts.join(' ') + '\n';
|
|
51
|
+
};
|
|
52
|
+
const testFileName = `${tempFolder}/b.test.js`;
|
|
53
|
+
const thing = 'Sample test 2';
|
|
54
|
+
const should = '2 should equal 2';
|
|
55
|
+
if (existsSync(testFileName)) {
|
|
56
|
+
await fs.unlink(testFileName);
|
|
57
|
+
}
|
|
58
|
+
existsSync(testFileName).should.equal(false);
|
|
59
|
+
await watchFilesAndRunTestsNodeWatch(config, [], {}, [], customOut);
|
|
60
|
+
outBuffer.should.equal('');
|
|
61
|
+
void fs.writeFile(testFileName, `import { describe } from '../../dist/index.js'
|
|
73
62
|
import { expect, should } from 'chai'
|
|
74
63
|
should()
|
|
75
64
|
|
|
@@ -80,30 +69,24 @@ describe('${thing}', ({it}) => {
|
|
|
80
69
|
})
|
|
81
70
|
|
|
82
71
|
})`);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
102
|
-
const testFileName = `${tempFolder}/c.test.js`;
|
|
103
|
-
const thing = 'Sample test 3';
|
|
104
|
-
const should = '3 should equal 3';
|
|
105
|
-
if (!(await existsSync(testFileName))) {
|
|
106
|
-
await fs.writeFile(testFileName, `import { describe } from '../../dist/index.js'
|
|
72
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
73
|
+
outBuffer.should.include(testFileName);
|
|
74
|
+
outBuffer.should.include(thing);
|
|
75
|
+
outBuffer.should.include(should);
|
|
76
|
+
outBuffer.should.include(figures.tick);
|
|
77
|
+
});
|
|
78
|
+
mochaIt('removes a test from tests and dependencyTrees when it is deleted', async function () {
|
|
79
|
+
const config = structuredClone(baseConfig);
|
|
80
|
+
// create a custom out function to capture the output
|
|
81
|
+
let outBuffer = '';
|
|
82
|
+
const customOut = (...texts) => {
|
|
83
|
+
outBuffer += texts.join(' ') + '\n';
|
|
84
|
+
};
|
|
85
|
+
const testFileName = `${tempFolder}/c.test.js`;
|
|
86
|
+
const thing = 'Sample test 3';
|
|
87
|
+
const should = '3 should equal 3';
|
|
88
|
+
if (!existsSync(testFileName)) {
|
|
89
|
+
await fs.writeFile(testFileName, `import { describe } from '../../dist/index.js'
|
|
107
90
|
import { expect, should } from 'chai'
|
|
108
91
|
should()
|
|
109
92
|
|
|
@@ -114,20 +97,24 @@ describe('${thing}', ({it}) => {
|
|
|
114
97
|
})
|
|
115
98
|
|
|
116
99
|
})`);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
100
|
+
}
|
|
101
|
+
existsSync(testFileName).should.be.true;
|
|
102
|
+
const originalTests = [testFileName];
|
|
103
|
+
const originalDependencyTrees = {
|
|
104
|
+
[testFileName]: [
|
|
105
|
+
'dep-1.js',
|
|
106
|
+
'dep-2.js'
|
|
107
|
+
]
|
|
108
|
+
};
|
|
109
|
+
const tests = structuredClone(originalTests);
|
|
110
|
+
const dependencyTrees = structuredClone(originalDependencyTrees);
|
|
111
|
+
tests.should.include.members([testFileName]);
|
|
112
|
+
dependencyTrees.should.include.keys([testFileName]);
|
|
113
|
+
await watchFilesAndRunTestsNodeWatch(config, tests, dependencyTrees, [], customOut);
|
|
114
|
+
await fs.unlink(testFileName);
|
|
115
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
116
|
+
tests.should.not.include.members([testFileName]);
|
|
117
|
+
dependencyTrees.should.not.include.keys([testFileName]);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=watchFilesAndRunTestsNodeWatch.unitTest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchFilesAndRunTestsNodeWatch.unitTest.js","sourceRoot":"","sources":["../../../src/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/C,OAAO,OAAO,MAAM,2BAA2B,CAAA;AAE/C,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAA;AACpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAG9D,aAAa,CAAC,2CAA2C,EAAE;IACvD,MAAM,UAAU,GAAG,2CAA2C,CAAA;IAE9D,MAAM,UAAU,GAAG,mBAAmB,CAAC;QACnC,SAAS,EAAE,UAAU;QACrB,KAAK,EAAE,cAAc;QACrB,KAAK,EAAE;YACH,cAAc,EAAE,UAAU;YAC1B,UAAU,EAAE,SAAS;SACxB;KACJ,CAAC,CAAA;IAEF,OAAO,CAAC,+CAA+C,EAAE,KAAK;QAC1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AAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,CAAA;QAChD,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,CAAA;IAC3D,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -1,60 +1,34 @@
|
|
|
1
|
-
import { createTimeProfiler } from '
|
|
1
|
+
import { createTimeProfiler } from '../../packages/timeProfiler.js';
|
|
2
2
|
import { showTimeProfiling } from '../../config.js';
|
|
3
|
-
import
|
|
4
|
-
import minimatch from 'minimatch';
|
|
5
|
-
import slash from 'slash';
|
|
6
|
-
//import watch from 'node-watch'
|
|
3
|
+
import slash from '../../packages/slash.js';
|
|
7
4
|
import chokidar from 'chokidar';
|
|
8
|
-
|
|
9
|
-
import fs, { watch } from 'fs';
|
|
10
|
-
import { out, log, debug } from '../../output.js';
|
|
11
|
-
import { globArgCombine } from './globArgCombine.js';
|
|
5
|
+
import { out, debug } from '../../output.js';
|
|
12
6
|
import { addBasePath } from './addBasePath.js';
|
|
13
|
-
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
7
|
+
const { timeProfileAsync } = createTimeProfiler(showTimeProfiling);
|
|
8
|
+
export function watchFilesChokidar(config, onEvent) {
|
|
9
|
+
return timeProfileAsync('start watching', () => {
|
|
10
|
+
if (config.watch.watchFilesBase === '') {
|
|
11
|
+
out('No config.watch.watchFilesBase provided, defaulting to \'.\'');
|
|
12
|
+
config.watch.watchFilesBase = '.';
|
|
13
|
+
}
|
|
14
|
+
const ignoreGlob = config.watch.watchFilesIgnore.length > 0
|
|
15
|
+
? addBasePath(config.watch.watchFilesBase, config.watch.watchFilesIgnore)
|
|
16
|
+
: undefined;
|
|
17
|
+
const watcher = chokidar.watch(config.watch.watchFilesBase, {
|
|
18
|
+
ignored: ignoreGlob,
|
|
19
|
+
ignoreInitial: true
|
|
20
|
+
});
|
|
21
|
+
watcher.on('all', (event, filename) => {
|
|
22
|
+
filename = slash(filename);
|
|
23
|
+
debug('[watch event]', filename, event);
|
|
24
|
+
onEvent(filename, (event === 'unlink') ? 'remove' : event);
|
|
25
|
+
});
|
|
26
|
+
return new Promise(resolve => {
|
|
27
|
+
watcher.on('ready', () => {
|
|
28
|
+
debug('chokidar watcher ready');
|
|
29
|
+
resolve(watcher);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
37
32
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
filename = await slash(filename);
|
|
41
|
-
await debug('[watch event]', filename, event);
|
|
42
|
-
await onEvent(filename, event === 'unlink' ? 'remove' : event);
|
|
43
|
-
});
|
|
44
|
-
return new Promise(async (resolve, reject) => {
|
|
45
|
-
await watcher.on('ready', async () => {
|
|
46
|
-
//log('chokidar watcher ready')
|
|
47
|
-
await debug('chokidar watcher ready');
|
|
48
|
-
await resolve(watcher);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// watch(config.watch.watchFilesBase, { recursive: true, filter: watchFilter }, function(event, filename) {
|
|
53
|
-
// filename = slash(filename)
|
|
54
|
-
// debug('watch event')
|
|
55
|
-
// onEvent(filename, event)
|
|
56
|
-
// })
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
//return new Promise( () => {} ) // infinite promise to let us watch
|
|
60
|
-
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=watchFilesChokidar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchFilesChokidar.js","sourceRoot":"","sources":["../../../src/cli/lib/watchFilesChokidar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"watchFilesChokidar.js","sourceRoot":"","sources":["../../../src/cli/lib/watchFilesChokidar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,MAAM,yBAAyB,CAAA;AAC3C,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAK9C,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AAElE,MAAM,UAAU,kBAAkB,CAAC,MAAc,EAAE,OAAmB;IAClE,OAAO,gBAAgB,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC3C,IAAI,MAAM,CAAC,KAAK,CAAC,cAAc,KAAK,EAAE,EAAE,CAAC;YACrC,GAAG,CAAC,8DAA8D,CAAC,CAAA;YACnE,MAAM,CAAC,KAAK,CAAC,cAAc,GAAG,GAAG,CAAA;QACrC,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC;YACvD,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC;YACzE,CAAC,CAAC,SAAS,CAAA;QAEf,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAC1B,MAAM,CAAC,KAAK,CAAC,cAAc,EAC3B;YACI,OAAO,EAAE,UAAU;YACnB,aAAa,EAAE,IAAI;SACtB,CACJ,CAAA;QAED,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;YAClC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAA;YAC1B,KAAK,CAAC,eAAe,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;YACvC,OAAO,CACH,QAAQ,EACR,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAC1C,CAAA;QACL,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YACzB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;gBACrB,KAAK,CAAC,wBAAwB,CAAC,CAAA;gBAC/B,OAAO,CAAC,OAAO,CAAC,CAAA;YACpB,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchFilesChokidar.unitTest.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/watchFilesChokidar.unitTest.ts"],"names":[],"mappings":""}
|
|
@@ -1,88 +1,84 @@
|
|
|
1
1
|
import { promises as fs } from 'fs';
|
|
2
2
|
import { watchFilesChokidar } from './watchFilesChokidar.js';
|
|
3
3
|
import { applyConfigDefaults } from './applyConfigDefaults.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
mochaDescribe('watchFilesChokidar() function', function () {
|
|
5
|
+
mochaIt('should call back when when a file change occurs', async function () {
|
|
6
|
+
this.timeout(12000);
|
|
7
|
+
const config = applyConfigDefaults({});
|
|
8
|
+
let eventComplete = false;
|
|
9
|
+
await watchFilesChokidar(config, () => {
|
|
10
|
+
eventComplete = true;
|
|
11
|
+
});
|
|
12
|
+
void fs.writeFile('watchTests/watchFilesChokidar-file.js', 'abc');
|
|
13
|
+
await new Promise(resolve => {
|
|
14
|
+
const interval = setInterval(() => {
|
|
15
|
+
if (eventComplete) {
|
|
16
|
+
clearInterval(interval);
|
|
17
|
+
resolve();
|
|
18
|
+
}
|
|
19
|
+
}, 50);
|
|
20
|
+
});
|
|
21
|
+
eventComplete.should.equal(true);
|
|
14
22
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
mochaIt('should call back when when a file change occurs in specified folder', async function () {
|
|
24
|
+
this.timeout(12000);
|
|
25
|
+
const config = applyConfigDefaults({
|
|
26
|
+
watch: {
|
|
27
|
+
watchFilesBase: 'watchTests/watchFilesChokidar',
|
|
28
|
+
watchFiles: '**/*.js'
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
let eventComplete = false;
|
|
32
|
+
await watchFilesChokidar(config, () => {
|
|
33
|
+
eventComplete = true;
|
|
34
|
+
});
|
|
35
|
+
void fs.writeFile('watchTests/watchFilesChokidar/a-file.js', 'abc');
|
|
36
|
+
await new Promise(resolve => {
|
|
37
|
+
const interval = setInterval(() => {
|
|
38
|
+
if (eventComplete) {
|
|
39
|
+
clearInterval(interval);
|
|
40
|
+
resolve();
|
|
41
|
+
}
|
|
42
|
+
}, 50);
|
|
43
|
+
});
|
|
44
|
+
eventComplete.should.equal(true);
|
|
23
45
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
mochaIt('ignores a file based on ignore glob', async function () {
|
|
47
|
+
this.timeout(12000);
|
|
48
|
+
const config = applyConfigDefaults({
|
|
49
|
+
watch: {
|
|
50
|
+
watchFilesBase: 'watchTests/watchFilesChokidar',
|
|
51
|
+
watchFiles: '**/*.js',
|
|
52
|
+
watchFilesIgnore: 'ignore-file.js'
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
let eventComplete = false;
|
|
56
|
+
await watchFilesChokidar(config, () => {
|
|
57
|
+
eventComplete = true;
|
|
58
|
+
});
|
|
59
|
+
void fs.writeFile('watchTests/watchFilesChokidar/ignore-file.js', 'abc');
|
|
60
|
+
await new Promise(resolve => {
|
|
61
|
+
setTimeout(resolve, 1000);
|
|
62
|
+
});
|
|
63
|
+
eventComplete.should.not.equal(true);
|
|
33
64
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
65
|
+
mochaIt('ignores a file based on ignore globs array', async function () {
|
|
66
|
+
const config = applyConfigDefaults({
|
|
67
|
+
watch: {
|
|
68
|
+
watchFilesBase: 'watchTests/watchFilesChokidar',
|
|
69
|
+
watchFiles: '**/*.js',
|
|
70
|
+
watchFilesIgnore: ['first-ignore-file.js', 'ignore-file.js']
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
let eventComplete = false;
|
|
74
|
+
await watchFilesChokidar(config, () => {
|
|
75
|
+
eventComplete = true;
|
|
76
|
+
});
|
|
77
|
+
void fs.writeFile('watchTests/watchFilesChokidar/ignore-file.js', 'abc');
|
|
78
|
+
await new Promise(resolve => {
|
|
79
|
+
setTimeout(resolve, 1000);
|
|
80
|
+
});
|
|
81
|
+
eventComplete.should.not.equal(true);
|
|
37
82
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const interval = await setInterval(async () => {
|
|
41
|
-
if (eventComplete) {
|
|
42
|
-
await clearInterval(interval);
|
|
43
|
-
await resolve();
|
|
44
|
-
}
|
|
45
|
-
}, 50);
|
|
46
|
-
});
|
|
47
|
-
await eventComplete.should.equal(true);
|
|
48
|
-
});
|
|
49
|
-
await mochaIt('ignores a file based on ignore glob', async function () {
|
|
50
|
-
await this.timeout(12000);
|
|
51
|
-
const config = await applyConfigDefaults({
|
|
52
|
-
watch: {
|
|
53
|
-
watchFilesBase: 'watchTests/watchFilesChokidar',
|
|
54
|
-
watchFiles: '**/*.js',
|
|
55
|
-
watchFilesIgnore: 'ignore-file.js'
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
let eventComplete = false;
|
|
59
|
-
await watchFilesChokidar(config, async (filename, event) => {
|
|
60
|
-
eventComplete = true;
|
|
61
|
-
});
|
|
62
|
-
await fs.writeFile('watchTests/watchFilesChokidar/ignore-file.js', 'abc');
|
|
63
|
-
await new Promise(async (resolve, reject) => {
|
|
64
|
-
await setTimeout(resolve, 1000);
|
|
65
|
-
});
|
|
66
|
-
await eventComplete.should.not.equal(true);
|
|
67
|
-
});
|
|
68
|
-
await mochaIt('ignores a file based on ignore globs array', async function () {
|
|
69
|
-
//this.timeout(100000)
|
|
70
|
-
|
|
71
|
-
const config = await applyConfigDefaults({
|
|
72
|
-
watch: {
|
|
73
|
-
watchFilesBase: 'watchTests/watchFilesChokidar',
|
|
74
|
-
watchFiles: '**/*.js',
|
|
75
|
-
watchFilesIgnore: ['first-ignore-file.js', 'ignore-file.js']
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
let eventComplete = false;
|
|
79
|
-
await watchFilesChokidar(config, async (filename, event) => {
|
|
80
|
-
eventComplete = true;
|
|
81
|
-
});
|
|
82
|
-
await fs.writeFile('watchTests/watchFilesChokidar/ignore-file.js', 'abc');
|
|
83
|
-
await new Promise(async (resolve, reject) => {
|
|
84
|
-
await setTimeout(resolve, 1000);
|
|
85
|
-
});
|
|
86
|
-
await eventComplete.should.not.equal(true);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=watchFilesChokidar.unitTest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchFilesChokidar.unitTest.js","sourceRoot":"","sources":["../../../src/cli/lib/watchFilesChokidar.unitTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAA;AAEnC,OAAO,EAAE,kBAAkB,EAAE,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gBAAgB,CAAC;aAC/D;SACJ,CAAC,CAAA;QAEF,IAAI,aAAa,GAAG,KAAK,CAAA;QAEzB,MAAM,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE;YAClC,aAAa,GAAG,IAAI,CAAA;QACxB,CAAC,CAAC,CAAA;QAEF,KAAK,EAAE,CAAC,SAAS,CAAC,8CAA8C,EAAE,KAAK,CAAC,CAAA;QAExE,MAAM,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE;YAC9B,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAC7B,CAAC,CAAC,CAAA;QAEF,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACxC,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -1,45 +1,35 @@
|
|
|
1
|
-
import { createTimeProfiler } from '
|
|
1
|
+
import { createTimeProfiler } from '../../packages/timeProfiler.js';
|
|
2
2
|
import { showTimeProfiling } from '../../config.js';
|
|
3
|
-
import chalk from 'chalk-extensions';
|
|
4
3
|
import minimatch from 'minimatch';
|
|
5
|
-
import slash from 'slash';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
//import nsfw from 'nsfw'
|
|
9
|
-
import fs from 'fs';
|
|
10
|
-
import { out, log, debug } from '../../output.js';
|
|
4
|
+
import slash from '../../packages/slash.js';
|
|
5
|
+
import * as nodeWatchNS from 'node-watch';
|
|
6
|
+
import { out, debug } from '../../output.js';
|
|
11
7
|
import { globArgCombine } from './globArgCombine.js';
|
|
12
|
-
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
8
|
+
const { timeProfileAsync } = createTimeProfiler(showTimeProfiling);
|
|
9
|
+
const nodeWatch = nodeWatchNS.default;
|
|
10
|
+
export function watchFilesNodeWatch(config, onEvent) {
|
|
11
|
+
return timeProfileAsync('start watching', async () => {
|
|
12
|
+
// identify a file we should be watching and responding to
|
|
13
|
+
const watchFilter = (file) => (config.watch.watchFiles.length === 0 || minimatch(file, globArgCombine(config.watch.watchFiles)))
|
|
14
|
+
&& (config.watch.watchFilesIgnore.length === 0
|
|
15
|
+
|| !minimatch(file, globArgCombine(config.watch.watchFilesIgnore)));
|
|
16
|
+
if (config.watch.watchFilesBase === '') {
|
|
17
|
+
out('No config.watch.watchFilesBase provided, defaulting to \'.\'');
|
|
18
|
+
config.watch.watchFilesBase = '.';
|
|
19
|
+
}
|
|
20
|
+
const watcher = nodeWatch(config.watch.watchFilesBase, {
|
|
21
|
+
recursive: true,
|
|
22
|
+
filter: watchFilter
|
|
23
|
+
}, (event, filename) => {
|
|
24
|
+
filename = slash(filename);
|
|
25
|
+
debug('watch event');
|
|
26
|
+
onEvent(filename, event);
|
|
27
|
+
});
|
|
28
|
+
// wait until the watcher is ready
|
|
29
|
+
await new Promise(resolve => {
|
|
30
|
+
watcher.on('ready', resolve);
|
|
31
|
+
});
|
|
32
|
+
return watcher;
|
|
35
33
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
await new Promise(async (resolve, reject) => {
|
|
39
|
-
await watcher.on('ready', resolve);
|
|
40
|
-
});
|
|
41
|
-
return watcher;
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
//return new Promise( () => {} ) // infinite promise to let us watch
|
|
45
|
-
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=watchFilesNodeWatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchFilesNodeWatch.js","sourceRoot":"","sources":["../../../src/cli/lib/watchFilesNodeWatch.ts"],"names":[],"mappings":"AAAA,OAA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