Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Gulpfile JS path parsing on Windows #7

Open
dougaxe1 opened this issue Jul 25, 2017 · 1 comment
Open

Gulpfile JS path parsing on Windows #7

dougaxe1 opened this issue Jul 25, 2017 · 1 comment
Labels

Comments

@dougaxe1
Copy link
Member

gulpfile.babel.js contains JS path parsing logic which assumes *nix style slashes. On Windows 10, node 6.10.3, npm 3.10.10, npm gulp build will break the theme. The build pipeline removes all JS files in the dist directory before encountering this error leaving the dist directory empty.

The faulty logic appears in two locations:

// ...
	const getPaths = (path) => {
		const fileName = path.replace(project.js + '/', '').slice(0, -3);
// ...

and

// ...
	// read js files
	return gulp.src([`${project.js}/**/*.js`, `!_*.js`], { read: false })
		.pipe(vinylPaths((path) => {
			const fileName = path.replace(project.js + '/', '');
// ...

Example error on npm gulp build:

[23:14:38] rollup c:\Users\Douglas\Workspace\chemonics\wp-content\themes\chemonics\assets\js\map.js 3.05 kB
{ Error: ENOENT: no such file or directory, mkdir 'c:\Users\Douglas\Workspace\chemonics\wp-content\themes\chemonics\assets\dist\c:'
    at Error (native)
    at Object.fs.mkdirSync (fs.js:923:18)
    at mkdirpath (c:\Users\Douglas\Workspace\chemonics\wp-content\themes\chemonics\node_modules\rollup\src\utils\fs.js:12:3)
    at mkdirpath (c:\Users\Douglas\Workspace\chemonics\wp-content\themes\chemonics\node_modules\rollup\src\utils\fs.js:11:3)
    at mkdirpath (c:\Users\Douglas\Workspace\chemonics\wp-content\themes\chemonics\node_modules\rollup\src\utils\fs.js:11:3)
    at mkdirpath (c:\Users\Douglas\Workspace\chemonics\wp-content\themes\chemonics\node_modules\rollup\src\utils\fs.js:11:3)
    at mkdirpath (c:\Users\Douglas\Workspace\chemonics\wp-content\themes\chemonics\node_modules\rollup\src\utils\fs.js:11:3)
    at mkdirpath (c:\Users\Douglas\Workspace\chemonics\wp-content\themes\chemonics\node_modules\rollup\src\utils\fs.js:11:3)
    at mkdirpath (c:\Users\Douglas\Workspace\chemonics\wp-content\themes\chemonics\node_modules\rollup\src\utils\fs.js:11:3)
    at mkdirpath (c:\Users\Douglas\Workspace\chemonics\wp-content\themes\chemonics\node_modules\rollup\src\utils\fs.js:11:3)
  errno: -4058,
  code: 'ENOENT',
  syscall: 'mkdir',
  path: 'c:\\Users\\Douglas\\Workspace\\chemonics\\wp-content\\themes\\chemonics\\assets\\dist\\c:' }
@dougaxe1 dougaxe1 added the bug label Jul 25, 2017
@dougaxe1
Copy link
Member Author

dougaxe1 commented Jul 25, 2017

Possible fix is to replace slashes prior to slicing string:

const fileName = path.replace(/\\/g, '/').replace(project.js.replace(/\\/g, '/') + '/', '').slice(0, -3);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant