feat(build): Allow building in windows without admin priviledges
Closes #2873
This commit is contained in:

committed by
Tobias Bosch

parent
f827e1532e
commit
f1f578436b
@ -41,7 +41,11 @@ class DiffingReplace implements DiffingBroccoliPlugin {
|
||||
});
|
||||
fs.writeFileSync(destFilePath, content, FILE_ENCODING);
|
||||
} else if (!fs.existsSync(destFilePath)) {
|
||||
fs.symlinkSync(sourceFilePath, destFilePath);
|
||||
try {
|
||||
fs.symlinkSync(sourceFilePath, destFilePath);
|
||||
} catch (e) {
|
||||
fs.writeFileSync(destFilePath, fs.readFileSync(sourceFilePath));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -15,12 +15,34 @@ module.exports = function(gulp, plugins, config) {
|
||||
var linkDir = path.join(nodeModulesDir, relativeFolder);
|
||||
if (!fs.existsSync(linkDir)) {
|
||||
console.log('creating link', linkDir, sourceDir);
|
||||
fs.symlinkSync(sourceDir, linkDir, 'dir');
|
||||
try {
|
||||
fs.symlinkSync(sourceDir, linkDir, 'dir');
|
||||
}
|
||||
catch(e) {
|
||||
var sourceDir = path.join(config.dir, relativeFolder);
|
||||
console.log('linking failed: trying to hard copy', linkDir, sourceDir);
|
||||
copyRecursiveSync(sourceDir, linkDir);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
function copyRecursiveSync (src, dest) {
|
||||
if (fs.existsSync(src)) {
|
||||
var stats = fs.statSync(src);
|
||||
if (stats.isDirectory()) {
|
||||
fs.mkdirSync(dest);
|
||||
fs.readdirSync(src).forEach(function(childItemName) {
|
||||
copyRecursiveSync(path.join(src, childItemName),
|
||||
path.join(dest, childItemName));
|
||||
});
|
||||
} else {
|
||||
fs.writeFileSync(dest, fs.readFileSync(src));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getSubdirs(rootDir) {
|
||||
return fs.readdirSync(rootDir).filter(function(file) {
|
||||
if (file[0] === '.') {
|
||||
@ -29,4 +51,4 @@ function getSubdirs(rootDir) {
|
||||
var dirPath = path.join(rootDir, file);
|
||||
return fs.statSync(dirPath).isDirectory();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user