Skip to content

Commit f8b1bba

Browse files
author
Ben Newman
committed
Improve .meteor/dev_bundle link reading and creation.
1 parent 74aea0c commit f8b1bba

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

tools/cli/dev-bundle-links.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
var fs = require("fs");
2+
var files = require("../fs/mini-files.js");
23

34
exports.makeLink = function (target, linkPath) {
5+
target = files.convertToOSPath(target);
6+
linkPath = files.convertToOSPath(linkPath);
7+
48
var tempPath = linkPath + "-" + Math.random().toString(36).slice(2);
59

610
try {
@@ -13,15 +17,14 @@ exports.makeLink = function (target, linkPath) {
1317
};
1418

1519
exports.readLink = function (linkPath) {
16-
var stat = fs.lstatSync(linkPath);
20+
linkPath = files.convertToOSPath(linkPath);
1721

22+
var stat = fs.lstatSync(linkPath);
1823
if (stat.isSymbolicLink()) {
19-
return fs.realpathSync(linkPath);
20-
}
21-
22-
if (stat.isFile()) {
23-
return fs.readFileSync(linkPath, "utf8");
24+
linkPath = fs.realpathSync(linkPath);
25+
} else if (stat.isFile()) {
26+
linkPath = fs.readFileSync(linkPath, "utf8");
2427
}
2528

26-
return linkPath;
29+
return files.convertToStandardPath(linkPath);
2730
};

tools/project-context.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,8 @@ _.extend(exports.ReleaseFile.prototype, {
13481348
},
13491349

13501350
ensureDevBundleLink() {
1351+
import { makeLink, readLink } from "./cli/dev-bundle-links.js";
1352+
13511353
// Make a symlink from .meteor/dev_bundle to the actual dev_bundle.
13521354
const devBundleLink = files.pathJoin(
13531355
files.pathDirname(this.filename),
@@ -1369,15 +1371,12 @@ _.extend(exports.ReleaseFile.prototype, {
13691371
const newTarget = files.realpath(files.getDevBundle());
13701372

13711373
try {
1372-
if (newTarget === files.realpath(devBundleLink)) {
1374+
if (newTarget === readLink(devBundleLink)) {
13731375
// Don't touch .meteor/dev_bundle if it already points to the
13741376
// right target path.
13751377
return;
13761378
}
13771379

1378-
// Remove .meteor/dev_bundle so that we can recreate it below.
1379-
files.rm_recursive(devBundleLink);
1380-
13811380
} catch (e) {
13821381
if (e.code !== "ENOENT") {
13831382
// It's ok if files.realpath(devBundleLink) failed because the
@@ -1386,10 +1385,7 @@ _.extend(exports.ReleaseFile.prototype, {
13861385
}
13871386
}
13881387

1389-
require("./cli/dev-bundle-links.js").makeLink(
1390-
files.convertToOSPath(newTarget),
1391-
files.convertToOSPath(devBundleLink)
1392-
);
1388+
makeLink(newTarget, devBundleLink);
13931389
},
13941390

13951391
write: function (releaseName) {

0 commit comments

Comments
 (0)