Skip to content

Commit

Permalink
Add option.installWithSymlinks to toggle symlink usage
Browse files Browse the repository at this point in the history
If enabled, the default assest.install will use symlinks rather then copying.
  • Loading branch information
stefanpenner committed Sep 13, 2017
1 parent 3126d85 commit 13e4f44
Show file tree
Hide file tree
Showing 3 changed files with 870 additions and 833 deletions.
11 changes: 8 additions & 3 deletions lib/assets/Assets.js
Expand Up @@ -4,7 +4,7 @@ var fs = require("fs-extra");
var path = require("path");
var URI = require("../util/URI");
var debug = require("../util/debug");

var ensureSymlink = require("ensure-symlink");
var AssetsCollection = require("./AssetsCollection");
// TODO - remove when deprecated AssetPathEntry is removed
var AssetsSource = require("./AssetsSource");
Expand Down Expand Up @@ -172,8 +172,13 @@ Assets.prototype.install = function(file, uri, cb) {
var dest = path.join(options.buildDir, uri);

try {
// we explicitly use copySync rather than copy to avoid starving system resources
fs.copySync(file, dest);
if (options.installWithSymlinks) {
fs.mkdirpSync(path.dirname(dest));
ensureSymlink(file, dest);
} else {
// we explicitly use copySync rather than copy to avoid starving system resources
fs.copySync(file, dest);
}
cb(null, dest);
} catch (error) {
error = new Error("Failed to install asset from " + file + "\n" + error.toString());
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -31,6 +31,7 @@
"archy": "^1.0.0",
"deasync": "^0.1.4",
"debug": "^2.2.0",
"ensure-symlink": "^1.0.0",
"fs-extra": "^0.30.0",
"glob": "^7.1.0",
"lodash.includes": "^4.3.0",
Expand Down

0 comments on commit 13e4f44

Please sign in to comment.