@haptiq/kit 0.5.0 → 0.6.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/bin/haptiq.kit.js CHANGED
@@ -87,6 +87,14 @@ async function loadConfig(verbose = false) {
87
87
  throw new Error('ship configuration must be an object');
88
88
  }
89
89
 
90
+ if (config.ship.src !== undefined && (typeof config.ship.src !== 'string' || config.ship.src.trim() === '')) {
91
+ throw new Error('ship.src must be a non-empty string');
92
+ }
93
+
94
+ if (config.ship.exclude !== undefined && !Array.isArray(config.ship.exclude)) {
95
+ throw new Error('ship.exclude must be an array');
96
+ }
97
+
90
98
  if (config.ship.targets) {
91
99
  if (typeof config.ship.targets !== 'object' || Array.isArray(config.ship.targets)) {
92
100
  throw new Error('ship.targets must be an object');
@@ -134,8 +142,8 @@ async function loadConfig(verbose = false) {
134
142
  */
135
143
  function createCommandHandler(taskName, taskFunction) {
136
144
  return async (...args) => {
137
- const options = args[args.length - 1];
138
- const positionalArgs = args.slice(0, -1);
145
+ const options = args[args.length - 2];
146
+ const positionalArgs = args.slice(0, -2);
139
147
  try {
140
148
  const config = await loadConfig(options.verbose);
141
149
  await taskFunction(config, options, ...positionalArgs);
package/lib/ship.js CHANGED
@@ -50,7 +50,7 @@ async function ship(config, verbose, options = {}) {
50
50
 
51
51
  for (const name of targetsToProcess) {
52
52
  const targetConfig = targets[name] ?? {};
53
- const dev = cliDev || targetConfig.dev || false;
53
+ const dev = (cliDev ?? targetConfig.dev) ?? false;
54
54
 
55
55
  await buildCSS(config, verbose, dev);
56
56
  await buildJS(config, verbose, { dev });
@@ -143,11 +143,13 @@ function rsyncDryRun(args) {
143
143
 
144
144
  let stdout = '';
145
145
  let stderr = '';
146
+ let rejected = false;
146
147
 
147
148
  childProcess.stdout.on('data', (data) => { stdout += data.toString(); });
148
149
  childProcess.stderr.on('data', (data) => { stderr += data.toString(); });
149
150
 
150
151
  childProcess.on('close', (code) => {
152
+ if (rejected) return;
151
153
  if (code === 0) {
152
154
  const deletions = stdout
153
155
  .split('\n')
@@ -160,6 +162,7 @@ function rsyncDryRun(args) {
160
162
  });
161
163
 
162
164
  childProcess.on('error', (err) => {
165
+ rejected = true;
163
166
  if (err.code === 'ENOENT') {
164
167
  reject(new Error('rsync not found. Please ensure rsync is installed on your system.'));
165
168
  } else {
@@ -231,6 +234,7 @@ function spawnRsync(args, verbose) {
231
234
  const childProcess = spawn('rsync', args, { shell: false });
232
235
 
233
236
  let stderr = '';
237
+ let rejected = false;
234
238
 
235
239
  if (verbose) {
236
240
  childProcess.stdout.on('data', (data) => process.stdout.write(data));
@@ -241,6 +245,7 @@ function spawnRsync(args, verbose) {
241
245
  });
242
246
 
243
247
  childProcess.on('close', (code) => {
248
+ if (rejected) return;
244
249
  if (code === 0) {
245
250
  resolve();
246
251
  } else {
@@ -249,6 +254,7 @@ function spawnRsync(args, verbose) {
249
254
  });
250
255
 
251
256
  childProcess.on('error', (err) => {
257
+ rejected = true;
252
258
  if (err.code === 'ENOENT') {
253
259
  reject(new Error('rsync not found. Please ensure rsync is installed on your system.'));
254
260
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haptiq/kit",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Build tools for Haptiq projects.",
5
5
  "keywords": [
6
6
  "build",