Skip to content

Commit

Permalink
Updated the git calls to create the base directory first, whcih fixes…
Browse files Browse the repository at this point in the history
… an issue on windows. Updated symlinks to support windows junctions. Updated a call to wrench to have a fully resolved path when recursively removing directories. Updated the meteor executable name when in windows to support the .bat extension. This seems to work on first attempt. Much more testing is needed.
  • Loading branch information
seanmwalker committed Nov 5, 2013
1 parent 188282f commit da6190d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/dependencies/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ Package.prototype.installInto = function(project, fn) {

// Make link if it doesn't exist, inform caller
if (! linkedTo) {
fs.symlinkSync(libPath, packagePath);
// Windows uses junctions to solve for symlinks. They need to be full paths too.
fs.symlinkSync(path.resolve(libPath), path.resolve(packagePath), 'junction');
self.addToGitIgnore(project);
fn(true);
} else {
Expand Down
13 changes: 10 additions & 3 deletions lib/meteor.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,18 @@ Meteor.prototype.ensurePrepared = function(fn) {

Meteor.prototype._executable = function() {
var self = this;

var executableName = 'meteor';
var isWin = !!process.platform.match(/^win/);

// Windows has a .bat file, we compensate for that here.
if (isWin) {
executableName += '.bat';
}

if (self.defaultMeteor) {
return 'meteor';
return executableName;
} else {
return path.join(self.source.packagePath(), 'meteor');
return path.join(self.source.packagePath(), executableName);
}
}

Expand Down
5 changes: 3 additions & 2 deletions lib/meteorite.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ Meteorite.prototype['link-package'] = function(fn) {

// pointing to the wrong spot
if (old)
fs.unlinkSync(packagePath);
fs.unlinkSync(path.resolve(packagePath));

fs.symlinkSync(packageDir, packagePath);
// Windows uses junctions to solve for symlinks. They need to be full paths too.
fs.symlinkSync(path.resolve(packageDir), path.resolve(packagePath), 'junction');
}

/////// Package level meteorite commands
Expand Down
16 changes: 14 additions & 2 deletions lib/sources/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,21 @@ GitSource.prototype._pull = function(fn) {
spawn('git', ['pull'], {cwd: this.sourcePath}).on('exit', fn);
};

// Patch for windows since it doesn't create the full path via gitbash.
GitSource.prototype._createBasePath = function(p) {
var self = this;

var basePath = path.dirname(p);
if (!fs.existsSync(basePath)) {
self._createBasePath(basePath);
fs.mkdirSync(basePath);
}
};

GitSource.prototype._clone = function(fn) {
var self = this;
if (!fs.existsSync(this.sourcePath)) {
self._createBasePath(this.sourcePath);
exec('git clone ' + self.url + ' "' + this.sourcePath + '"', function(err, stdout, stderr) {
if (err)
throw "There was a problem cloning repo: " + self.url +
Expand Down Expand Up @@ -135,7 +147,7 @@ GitSource.prototype._load = function(fn) {
// Cleanup
var gitDir = path.join(self.path, '.git');
if (!self.config.keepGitDir && fs.existsSync(gitDir))
wrench.rmdirSyncRecursive(gitDir);
wrench.rmdirSyncRecursive(path.resolve(gitDir));
fn();

});
Expand All @@ -146,7 +158,7 @@ GitSource.prototype._load = function(fn) {

GitSource.prototype._checkout = function(fn) {
var self = this;

self._createBasePath(this.sourcePath);
exec('git checkout ' + (this.commit || this.head), {cwd: this.sourcePath}, function(err, stdout, stderr) {
if (err)
throw "There was a problem checking out " + self.checkoutType + ": " + (self.commit || self.head);
Expand Down

0 comments on commit da6190d

Please sign in to comment.