@joystick.js/cli-canary 0.0.0-canary.97 → 0.0.0-canary.99

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/_package.json CHANGED
@@ -26,6 +26,7 @@
26
26
  "@babel/code-frame": "^7.15.8",
27
27
  "acorn": "^8.5.0",
28
28
  "ascii-table": "^0.0.9",
29
+ "ava": "^5.3.1",
29
30
  "chalk": "^4.1.2",
30
31
  "chokidar": "^3.5.2",
31
32
  "command-exists": "^1.2.9",
@@ -52,4 +53,4 @@
52
53
  "ws": "^8.2.3",
53
54
  "xmlhttprequest": "^1.8.0"
54
55
  }
55
- }
56
+ }
@@ -501,7 +501,6 @@ const dev = async (options, { resolve, reject }) => {
501
501
  nodeMajorVersion,
502
502
  __dirname
503
503
  });
504
- console.log(hmrProcess);
505
504
  processIds.push(hmrProcess.pid);
506
505
  process.hmrProcess = hmrProcess;
507
506
  handleHMRProcessSTDIO();
@@ -514,6 +513,9 @@ const dev = async (options, { resolve, reject }) => {
514
513
  );
515
514
  if (options?.environment === "test") {
516
515
  process.loader.text("Running tests...");
516
+ await runTests({
517
+ __dirname
518
+ });
517
519
  }
518
520
  resolve();
519
521
  } catch (exception) {
@@ -1,22 +1,58 @@
1
- const actionMethod = () => {
1
+ import child_process from "child_process";
2
+ const handleAvaSTDIO = (ava = {}) => {
2
3
  try {
4
+ ava.stdout.on("data", function(data) {
5
+ const string = data.toString();
6
+ if (!string?.includes("ava")) {
7
+ console.log(string);
8
+ }
9
+ });
10
+ ava.stderr.on("data", function(data) {
11
+ const string = data.toString();
12
+ if (!string?.includes("ava")) {
13
+ console.log(string);
14
+ }
15
+ });
3
16
  } catch (exception) {
4
- throw new Error(`[runTests.actionMethod] ${exception.message}`);
17
+ throw new Error(`[runTests.handleAvaSTDIO] ${exception.message}`);
18
+ }
19
+ };
20
+ const runAva = (__dirname = "") => {
21
+ try {
22
+ console.log(`node_modules/.bin/ava --config ${__dirname}/tests.config.js`);
23
+ return new Promise((resolve, reject) => {
24
+ const ava = child_process.exec(`node_modules/.bin/ava --config ${__dirname}/tests.config.js`, {
25
+ stdio: "inherit",
26
+ env: {
27
+ ...process.env,
28
+ FORCE_COLOR: "1"
29
+ }
30
+ }, (error) => {
31
+ if (error) {
32
+ return reject();
33
+ }
34
+ return resolve();
35
+ });
36
+ handleAvaSTDIO(ava);
37
+ });
38
+ } catch (exception) {
39
+ throw new Error(`[runTests.runAva] ${exception.message}`);
5
40
  }
6
41
  };
7
42
  const validateOptions = (options) => {
8
43
  try {
9
44
  if (!options)
10
45
  throw new Error("options object is required.");
11
- if (!options.port)
12
- throw new Error("options.port is required.");
46
+ if (!options.__dirname)
47
+ throw new Error("options.__dirname is required.");
13
48
  } catch (exception) {
14
49
  throw new Error(`[runTests.validateOptions] ${exception.message}`);
15
50
  }
16
51
  };
17
- const runTests = (options, { resolve, reject }) => {
52
+ const runTests = async (options, { resolve, reject }) => {
18
53
  try {
19
54
  validateOptions(options);
55
+ await runAva(options?.__dirname);
20
56
  resolve();
21
57
  } catch (exception) {
22
58
  reject(`[runTests] ${exception.message}`);
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joystick.js/cli-canary",
3
- "version": "0.0.0-canary.97",
3
+ "version": "0.0.0-canary.99",
4
4
  "type": "module",
5
5
  "description": "CLI for the Joystick JavaScript framework.",
6
6
  "main": "development.js",
@@ -600,8 +600,6 @@ const dev = async (options, { resolve, reject }) => {
600
600
  __dirname,
601
601
  });
602
602
 
603
- console.log(hmrProcess);
604
-
605
603
  processIds.push(hmrProcess.pid);
606
604
  process.hmrProcess = hmrProcess;
607
605
 
@@ -618,7 +616,9 @@ const dev = async (options, { resolve, reject }) => {
618
616
 
619
617
  if (options?.environment === 'test') {
620
618
  process.loader.text('Running tests...');
621
- // await runTests(options);
619
+ await runTests({
620
+ __dirname,
621
+ });
622
622
  }
623
623
 
624
624
  /*
@@ -1,26 +1,67 @@
1
- /* eslint-disable consistent-return */
1
+ import child_process from "child_process";
2
2
 
3
- const actionMethod = () => {
3
+ const handleAvaSTDIO = (ava = {}) => {
4
4
  try {
5
- // Perform a single step in your action here.
5
+ ava.stdout.on('data', function (data) {
6
+ const string = data.toString();
7
+
8
+ if (!string?.includes('ava')) {
9
+ console.log(string);
10
+ }
11
+ });
12
+
13
+ ava.stderr.on('data', function (data) {
14
+ const string = data.toString();
15
+
16
+ if (!string?.includes('ava')) {
17
+ console.log(string);
18
+ }
19
+ });
20
+ } catch (exception) {
21
+ throw new Error(`[runTests.handleAvaSTDIO] ${exception.message}`);
22
+ }
23
+ };
24
+
25
+ const runAva = (__dirname = '') => {
26
+ try {
27
+ console.log(`node_modules/.bin/ava --config ${__dirname}/tests.config.js`);
28
+ return new Promise((resolve, reject) => {
29
+ const ava = child_process.exec(`node_modules/.bin/ava --config ${__dirname}/tests.config.js`, {
30
+ stdio: 'inherit',
31
+ env: {
32
+ ...(process.env),
33
+ FORCE_COLOR: "1"
34
+ }
35
+ }, (error) => {
36
+ if (error) {
37
+ return reject();
38
+ }
39
+
40
+ return resolve();
41
+ });
42
+
43
+ handleAvaSTDIO(ava);
44
+ });
6
45
  } catch (exception) {
7
- throw new Error(`[runTests.actionMethod] ${exception.message}`);
46
+ throw new Error(`[runTests.runAva] ${exception.message}`);
8
47
  }
9
48
  };
10
49
 
11
50
  const validateOptions = (options) => {
12
51
  try {
13
52
  if (!options) throw new Error('options object is required.');
14
- if (!options.port) throw new Error('options.port is required.');
53
+ if (!options.__dirname) throw new Error('options.__dirname is required.');
15
54
  } catch (exception) {
16
55
  throw new Error(`[runTests.validateOptions] ${exception.message}`);
17
56
  }
18
57
  };
19
58
 
20
- const runTests = (options, { resolve, reject }) => {
59
+ const runTests = async (options, { resolve, reject }) => {
21
60
  try {
22
61
  validateOptions(options);
23
- // Call action methods in sequence here.
62
+
63
+ await runAva(options?.__dirname);
64
+
24
65
  resolve();
25
66
  } catch (exception) {
26
67
  reject(`[runTests] ${exception.message}`);
File without changes