X Tutup
Skip to content

Commit f1f5784

Browse files
alfonso-presatbosch
authored andcommitted
feat(build): Allow building in windows without admin priviledges
Closes #2873
1 parent f827e15 commit f1f5784

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

DEVELOPER.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ Karma is run against the new output.
181181
much easier to debug. `xit` and `xdescribe` can also be useful to exclude a test and a group of
182182
tests respectively.
183183

184+
**Note**: **watch mode** needs symlinks to work, so if you're using windows, ensure you have the
185+
rights to built them in your operating system.
186+
184187
### E2E tests
185188

186189
1. `$(npm bin)/gulp build.js.cjs` (builds benchpress and tests into `dist/js/cjs` folder).

tools/broccoli/broccoli-replace.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ class DiffingReplace implements DiffingBroccoliPlugin {
4141
});
4242
fs.writeFileSync(destFilePath, content, FILE_ENCODING);
4343
} else if (!fs.existsSync(destFilePath)) {
44-
fs.symlinkSync(sourceFilePath, destFilePath);
44+
try {
45+
fs.symlinkSync(sourceFilePath, destFilePath);
46+
} catch (e) {
47+
fs.writeFileSync(destFilePath, fs.readFileSync(sourceFilePath));
48+
}
4549
}
4650
});
4751

tools/build/linknodemodules.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,34 @@ module.exports = function(gulp, plugins, config) {
1515
var linkDir = path.join(nodeModulesDir, relativeFolder);
1616
if (!fs.existsSync(linkDir)) {
1717
console.log('creating link', linkDir, sourceDir);
18-
fs.symlinkSync(sourceDir, linkDir, 'dir');
18+
try {
19+
fs.symlinkSync(sourceDir, linkDir, 'dir');
20+
}
21+
catch(e) {
22+
var sourceDir = path.join(config.dir, relativeFolder);
23+
console.log('linking failed: trying to hard copy', linkDir, sourceDir);
24+
copyRecursiveSync(sourceDir, linkDir);
25+
}
1926
}
2027
});
2128
};
2229
};
2330

31+
function copyRecursiveSync (src, dest) {
32+
if (fs.existsSync(src)) {
33+
var stats = fs.statSync(src);
34+
if (stats.isDirectory()) {
35+
fs.mkdirSync(dest);
36+
fs.readdirSync(src).forEach(function(childItemName) {
37+
copyRecursiveSync(path.join(src, childItemName),
38+
path.join(dest, childItemName));
39+
});
40+
} else {
41+
fs.writeFileSync(dest, fs.readFileSync(src));
42+
}
43+
}
44+
}
45+
2446
function getSubdirs(rootDir) {
2547
return fs.readdirSync(rootDir).filter(function(file) {
2648
if (file[0] === '.') {
@@ -29,4 +51,4 @@ function getSubdirs(rootDir) {
2951
var dirPath = path.join(rootDir, file);
3052
return fs.statSync(dirPath).isDirectory();
3153
});
32-
}
54+
}

0 commit comments

Comments
 (0)
X Tutup