execFileSync find fails on Windows
Closed this issue · 1 comments
schindld commented
Line 20 in 7b25a76
☝️ this is Linux/Mac-specific code. It fails on Windows with "FIND: Parameter format not correct".
The find
command on windows is more like grep. The dir /s /b
command would be better.
Here's a cross-platform fix:
let stdout
if(os.platform() === 'win32') stdout = execFileSync('cmd', ['/c', 'dir', '/s', '/b', dirname])
else stdout = execFileSync('find', [dirname])
const dirs = String(stdout).split(os.EOL).filter(d => d)
Notice the os.EOL
as well, otherwise you end up with a leftover carriage return at the end of each line in Windows.
schindld commented
After getting past that error, the next OS-specific problem is at
Line 30 in 7b25a76
On Windows, the regular expression doesn't match the path separator (\). This works:
const filename = os.platform() === 'win32' ? f.replace(/.*\\(.+)\.html/, '$1') : f.replace(/.*\/(.+)\.html/, '$1')
With those two fixes in place, the build ran and output index.js and my component file in dist.