Allow running spacejam from any folder, not only from app or package folders
Closed this issue · 6 comments
I split my jade
package in two distinct parts and I now use the undocumented test-app-path
option to test both local packages at the same time. More context in this commit message: mquandalle/meteor-jade@6da3e81.
As the above message explains I use the following command to test my packages:
$ meteor test-packages --test-app-path . packages/*
and it works as expected. If I call the equivalent spacejam
command just after the above it also works as expected. However if I first remove the .meteor
directory, I get the following error:
$ spacejam test-packages --test-app-path . packages/*
Trace: [Error: spacejam needs to be run from within a meteor app or package folder.]
at Spacejam.testPackages (/usr/lib/node_modules/spacejam/lib/Spacejam.js:117:17)
at CLI.exec (/usr/lib/node_modules/spacejam/lib/CLI.js:126:53)
at Object.<anonymous> (/usr/lib/node_modules/spacejam/bin/spacejam:5:29)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
Since the .meteor
directory is not committed to the repository this is what happen in the Travis CI worker (see https://travis-ci.org/mquandalle/meteor-jade/builds/42870817).
Yes, we verify that either .meteor or package.js exists in the folder to avoid confusions. You can test both of them separately, by cding to their folder and using ./ as a workaround. I don't think I'd like to remove this check, though. What do you think?
Maybe add an “exception” for test-app-path
?
diff --git a/src/Meteor.coffee b/src/Meteor.coffee
index 45df605..a27b192 100755
--- a/src/Meteor.coffee
+++ b/src/Meteor.coffee
@@ -64,7 +64,9 @@ class Meteor extends EventEmitter
log.debug "meteor cwd=#{cwd}"
- if not fs.existsSync(cwd + '/.meteor/packages') and not fs.existsSync(cwd + '/package.js')
+ if not fs.existsSync(cwd + '/.meteor/packages') and
+ not fs.existsSync(cwd + '/package.js') and
+ not @options['test-packages']? # see https://github.com/practicalmeteor/spacejam/issues/17
throw new Error("spacejam needs to be run from within a meteor app or package folder.")
expect(@options['driver-package'], "options.driver-package is missing").to.be.ok
The idea is that if I use the --test-app-path .
option I don't need to be in a meteor app (or a package) because meteor will create the application for me.
Actually, --test-app-path is saying to meteor where to create the test app and not to create one, because it always creates one, usually in /tmp. You can check it for yourself, when you run meteor test-packages. I'll check if meteor allows me to test multiple packages without being in an app or package folder, and if it does, I'll remove this limitation.
Anyway you don't really need to to this check because you can rely on the underneath meteor test-packages
to raise an exception if needed.
OK, just checked. you are right. I just need to update some tests and I'll push it in the next version, in the next few days.
Published in v1.1.3