intlayer-editor 6.0.2 → 6.1.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.
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // bin/intlayer-editor.mjs
3
3
 
4
+ import { runParallel } from '@intlayer/chokidar';
4
5
  import { exec } from 'child_process';
5
6
  import { dirname, join } from 'path';
6
7
  import { fileURLToPath } from 'url';
@@ -17,10 +18,12 @@ const args = process.argv.slice(2);
17
18
 
18
19
  let env = 'production'; // Default environment
19
20
  let envFile = ''; // Default to no env file
21
+ let withCommand;
22
+ let parallelProcess = null;
20
23
 
21
24
  // Check for --env or -e flag
22
25
  const envIndex = args.findIndex(
23
- (arg) => arg === '---environment' || arg === '--env' || arg === '-e'
26
+ (arg) => arg === '---environment' ?? arg === '--env' ?? arg === '-e'
24
27
  );
25
28
  if (envIndex !== -1 && args[envIndex + 1]) {
26
29
  env = args[envIndex + 1]; // Get the next argument as the environment
@@ -28,12 +31,22 @@ if (envIndex !== -1 && args[envIndex + 1]) {
28
31
 
29
32
  // Check for --env-file or -f flag
30
33
  const envFileIndex = args.findIndex(
31
- (arg) => arg === '---env-file' || arg === '--env-file' || arg === '-f'
34
+ (arg) => arg === '---env-file' ?? arg === '--env-file' ?? arg === '-f'
32
35
  );
33
36
  if (envFileIndex !== -1 && args[envFileIndex + 1]) {
34
37
  envFile = args[envFileIndex + 1];
35
38
  }
36
39
 
40
+ // Check for --with flag
41
+ const withIndex = args.findIndex((arg) => arg === '--with');
42
+ if (withIndex !== -1 && args[withIndex + 1]) {
43
+ withCommand = args[withIndex + 1];
44
+ }
45
+
46
+ if (withCommand) {
47
+ runParallel(withCommand);
48
+ }
49
+
37
50
  if (args[0] === 'start') {
38
51
  // Start the server pointing to the package's 'dist' directory
39
52
  const command = `node ${distPath}`;
@@ -55,6 +68,9 @@ if (args[0] === 'start') {
55
68
  });
56
69
 
57
70
  child.on('error', (error) => {
71
+ if (parallelProcess) {
72
+ parallelProcess.kill();
73
+ }
58
74
  console.error(`Error starting the editor: ${error.message}`);
59
75
  process.exit(1);
60
76
  });
@@ -65,6 +81,10 @@ if (args[0] === 'start') {
65
81
  )
66
82
  return;
67
83
 
84
+ if (parallelProcess) {
85
+ parallelProcess.kill();
86
+ }
87
+
68
88
  console.info(`Child process exited with code ${code}`);
69
89
  });
70
90
  } else {