Skip to content

Commit cb57c6c

Browse files
devversionandrewseguin
authored andcommitted
build: throw when running build tasks inside of a directory with spaces (#14126)
Currently building Angular Material with gulp inside of directories that include spaces, does not work because `child_process.spawnSync` does not properly treat the whole path as binary and just considers everything after the first space as command line argument. We can fix these issues by ensuring that the binary is always located in the working directory. Also we would need to make sure that we wrap all `child_process` arguments with explict quotes because otherwise NodeJS would treat them as individual arguments (e.g. `path/to/my project/ -> ["path/to/my", "project"]) -- **TL;DR**: As this is just too much work for something we will eventually replace with Bazel, we are just printing an error message.
1 parent dfcba2b commit cb57c6c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

gulpfile.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66

77
const path = require('path');
88

9-
const tsconfigPath = path.join(__dirname, 'tools/gulp/tsconfig.json');
9+
const projectDir = __dirname;
10+
const tsconfigPath = path.join(projectDir, 'tools/gulp/tsconfig.json');
1011
const tsconfig = require(tsconfigPath);
1112

13+
if (projectDir.includes(' ')) {
14+
console.error('Error: Cannot run the Angular Material build tasks if the project is ' +
15+
'located in a directory with spaces in between. Please rename your project directory.');
16+
process.exit(1);
17+
}
18+
1219
// Register TS compilation.
1320
require('ts-node').register({
1421
project: tsconfigPath

0 commit comments

Comments
 (0)