wp-advads 1.0.37 → 1.0.39

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "wp-advads",
4
- "version": "1.0.37",
4
+ "version": "1.0.39",
5
5
  "description": "Create an Advanced Ads WordPress plugin ecosystem.",
6
6
  "author": {
7
7
  "name": "Shakeeb Ahmed",
@@ -3,6 +3,14 @@
3
3
  */
4
4
  import { spawn } from 'node:child_process'
5
5
 
6
+ function spawnArgv( file, args, spawnOpts ) {
7
+ if ( process.platform !== 'win32' ) {
8
+ return spawn( file, args, { ...spawnOpts, shell: false } )
9
+ }
10
+
11
+ return spawn( file, args, { ...spawnOpts, shell: true } )
12
+ }
13
+
6
14
  /**
7
15
  * Run a command in the terminal.
8
16
  *
@@ -38,7 +46,7 @@ export function execCommand( command, callback, options = {} ) {
38
46
  }
39
47
 
40
48
  const child = Array.isArray( command )
41
- ? spawn( command[0], command.slice( 1 ), { ...spawnOpts, shell: false } )
49
+ ? spawnArgv( command[0], command.slice( 1 ), spawnOpts )
42
50
  : spawn( command, { ...spawnOpts, shell: true } )
43
51
 
44
52
  let stdout = ''
@@ -3,7 +3,7 @@
3
3
  * TASK-005: argv is not interpolated through a shell.
4
4
  */
5
5
  import assert from 'node:assert/strict'
6
- import { existsSync, rmSync } from 'node:fs'
6
+ import { existsSync, readFileSync, rmSync } from 'node:fs'
7
7
  import { tmpdir } from 'node:os'
8
8
  import { join } from 'node:path'
9
9
  import { test } from 'node:test'
@@ -130,3 +130,11 @@ test( 'execCommand does not ENOBUFS on stdout larger than 1MB', async () => {
130
130
  console.log = originalLog
131
131
  }
132
132
  } )
133
+
134
+ test( 'Windows argv spawn uses a shell so PATHEXT commands like wp.cmd resolve', () => {
135
+ const src = readFileSync( new URL( '../src/utilities/shell.js', import.meta.url ), 'utf8' )
136
+ const spawnArgv = src.split( 'function spawnArgv' )[1].split( 'export function' )[0]
137
+ assert.match( spawnArgv, /process\.platform !== 'win32'/ )
138
+ assert.match( spawnArgv, /shell:\s*false/ )
139
+ assert.match( spawnArgv, /shell:\s*true/ )
140
+ } )