diff --git a/lib/atmosphere.js b/lib/atmosphere.js index 89350e4..6d31cd2 100644 --- a/lib/atmosphere.js +++ b/lib/atmosphere.js @@ -15,14 +15,14 @@ var writeUserTokenFile = function(user) { var cfg = { user: user }; - var filePath = path.join(process.env.HOME, '.mrt.cfg'); + var filePath = path.join(process.env.HOME || process.env.HOMEPATH, '.mrt.cfg'); fs.writeFileSync(filePath, JSON.stringify(cfg)); fs.chmodSync(filePath, '0600'); }; var readUserTokenFile = function() { - var filePath = path.join(process.env.HOME, '.mrt.cfg'); + var filePath = path.join(process.env.HOME || process.env.HOMEPATH, '.mrt.cfg'); var fileContents = fs.readFileSync(filePath); return JSON.parse(fileContents); diff --git a/lib/meteor.js b/lib/meteor.js index 14cd228..20d78c4 100644 --- a/lib/meteor.js +++ b/lib/meteor.js @@ -7,6 +7,7 @@ var fstream = require('fstream'); var wrench = require('wrench'); var spawn = require('child_process').spawn; var exec = require('child_process').exec; +var which = require('which'); // A 'Meteor' refers to a single commit (branch, tag) of a version of the core meteor @@ -75,7 +76,8 @@ Meteor.prototype.install = function(buildDevBundle, fn) { } else { // meteor --help installs the dev bundle before doing anything else console.log('Downloading Meteor development bundle'); - var meteor = spawn('./meteor', ['--help'], {cwd: self.source.path}); + //var meteor = spawn('./meteor', ['--help'], {cwd: self.source.path}); + var meteor = spawn(self._executable(), ['--help'], {cwd: self.source.path}); // just output the status bar meteor.stderr.pipe(process.stderr); @@ -95,6 +97,8 @@ Meteor.prototype.ensurePrepared = function(fn) { } }; +/* +// Saving the original function so we can revert quickly once spawn-cmd is in place. Meteor.prototype._executable = function() { var self = this; @@ -104,6 +108,19 @@ Meteor.prototype._executable = function() { return path.join(self.source.packagePath(), 'meteor'); } } +*/ + +// Temporary code to be ripped out once spawn-cmd is in place. +Meteor.prototype._executable = function() { + var self = this; + var executableName = path.basename(which.sync('meteor')); + + if (self.defaultMeteor) { + return executableName; + } else { + return path.join(self.source.packagePath(), executableName); + } +} // run a command using just this checked-out version of meteor Meteor.prototype.execute = function(args, package_dir, fn) { @@ -140,7 +157,7 @@ Meteor.prototype.hasPackage = function(pkgName, fn) { if (!self.packageNames) { // we have to call meteor list because there's no obvious place to look - exec('meteor list', function(error, list) { + exec(self._executable() + ' list', function(error, list) { var lines = list.split('\n'); self.packageNames = _.map(lines, function(l) { diff --git a/lib/meteorite.js b/lib/meteorite.js index a876bcc..006c4e6 100644 --- a/lib/meteorite.js +++ b/lib/meteorite.js @@ -107,9 +107,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 @@ -229,7 +230,7 @@ _.each([ // Class methods Meteorite.root = function() { - var homeDir = process.env.HOME; + var homeDir = process.env.HOME || process.env.HOMEPATH; return path.join(homeDir, '.meteorite'); }; diff --git a/package.json b/package.json index 73218d9..89d6270 100644 --- a/package.json +++ b/package.json @@ -7,13 +7,14 @@ , "dependencies": { "ddp": ">=0.3.1" , "underscore": "1.3.3" - , "wrench": "1.3.9" + , "wrench": ">=1.5.5" , "fstream": ">=0.1.18" , "optimist": ">=0.3.4" , "prompt": "0.2.11" , "colors": "0.6.0-1" , "async": "0.2.9" , "rolling_timeout_exec": ">=0.0.1" + , "which": ">=1.0.5" } , "devDependencies": { "mocha": ">=1.2.2" @@ -28,5 +29,5 @@ { "type" : "git" , "url" : "https://github.com/oortcloud/meteorite.git" } -, "bin" : { "mrt" : "./bin/mrt.js" } +, "bin" : { "mrt" : "./bin/mrt.js", "meteorite" : "./bin/mrt.js" } } diff --git a/spec/acceptance/test_spec.js b/spec/acceptance/test_spec.js index e09494f..96ca734 100644 --- a/spec/acceptance/test_spec.js +++ b/spec/acceptance/test_spec.js @@ -3,6 +3,7 @@ var fs = require('fs'); var wrench = require('wrench'); var _ = require('underscore'); var ddp = require('ddp'); +var which = require('which'); var utils = require('../lib/utils.js'); var atmosphere = require('../lib/atmosphere.js'); @@ -15,8 +16,11 @@ var appDir = path.join(appHome, 'app'); before(function(done){ // ensure our "cached" CURL is in the path + process.env._METEORITE_REAL_GIT = which.sync('git'); process.env.PATH = [path.resolve(path.join('spec', 'support', 'bin')), process.env.PATH].join(':'); - + process.env._METEORITE_REAL_CURL = which.sync('curl'); + process.env._METEORITE_REAL_METEOR = path.basename(which.sync('meteor')); + // make sure Meteor doesn't try to install into our soon to be clean home dir process.env.METEOR_WAREHOUSE_DIR = path.join(process.env.HOME, '.meteor'); @@ -27,7 +31,7 @@ before(function(done){ console.log("Preparing..") // ensure we have the latest dev bundle cached console.log(" Ensuring we have the dev bundle for system meteor"); - utils.downloadDevBundle('meteor', function() { + utils.downloadDevBundle(process.env._METEORITE_REAL_METEOR, function() { // ensure we have dev bundles for all our meteor forks // XXX: // for meteor in meteors/ @@ -62,4 +66,4 @@ beforeEach(function() { } } fs.mkdirSync(appHome); -}); +}); \ No newline at end of file diff --git a/spec/support/bin/curl b/spec/support/bin/curl index ec0d4f3..0a4df89 100755 --- a/spec/support/bin/curl +++ b/spec/support/bin/curl @@ -8,6 +8,7 @@ var wrench = require('wrench'); var args = process.argv; var fileNameParts = args[args.length - 1].split('/'); var fileName = fileNameParts[fileNameParts.length - 1]; +var REAL_CURL = process.env._METEORITE_REAL_CURL; console.error('CURL called for ', fileName); @@ -15,7 +16,7 @@ if (! fileName.match(/^dev_bundle_/)) { // if it's not the dev bundle we are looking for, bail out to standard curl console.error('skipping...') - spawn('/usr/bin/curl', process.argv.slice(2)); + spawn(REAL_CURL, process.argv.slice(2)); } else { // it's a dev bundle, so cache it @@ -35,7 +36,7 @@ if (! fileName.match(/^dev_bundle_/)) { var url = process.argv[process.argv.length - 1]; - var curlCache = spawn('/usr/bin/curl', ['-O', url], { cwd: cachePath }, function() {}); + var curlCache = spawn(REAL_CURL, ['-O', url], { cwd: cachePath }, function() {}); curlCache.on('exit', outputFile); diff --git a/spec/support/bin/git b/spec/support/bin/git index 94f224f..3ec6a3c 100755 --- a/spec/support/bin/git +++ b/spec/support/bin/git @@ -15,6 +15,12 @@ var copyRepo = function(from, to) { spawn('cp', ['-r', from, to]); }; +var REAL_GIT = process.env._METEORITE_REAL_GIT; +if (!REAL_GIT) { + console.error('No _METEORITE_REAL_GIT specified'); + process.exit(1); +} + if (command === 'clone') { var cachePath = path.join(__dirname, '..', 'cache'); @@ -31,7 +37,7 @@ if (command === 'clone') { if (!fs.existsSync(repoCachePath)) { args.push(repoUrl); args.push(repoCachePath); - var git = spawn('/usr/local/bin/git', args); + var git = spawn(REAL_GIT, args); git.on('exit', function() { copyRepo(repoCachePath, destPath); @@ -44,7 +50,7 @@ if (command === 'clone') { } else if (command !== 'pull') { // we will skip pulls, expensive and redudant. - var git = spawn('/usr/local/bin/git', args); + var git = spawn(REAL_GIT, args); git.stderr.pipe(process.stderr); git.stdout.pipe(process.stdout);