cli: enable returning node module interface

-have binary call directly into the CLI
This commit is contained in:
Brian Mann
2017-06-05 18:31:44 -04:00
parent dc99198efc
commit dc9b835a58
3 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
#!/usr/bin/env node
require("../")
require("../lib/cli").init()
+3 -1
View File
@@ -10,6 +10,7 @@ function installingFromNpmAsAUser () {
return process.env.CYPRESS_DOWNLOAD !== "0"
}
// we're being used from the command line
switch (args.exec) {
case 'install':
// only go out and download the cypress
@@ -20,5 +21,6 @@ switch (args.exec) {
}
break
default:
require('./lib/cli').init()
// export our node module interface
module.exports = require("./lib/cypress")
}
+7 -2
View File
@@ -1,3 +1,5 @@
// https://github.com/cypress-io/cypress/issues/316
const Promise = require('bluebird')
const fs = Promise.promisifyAll(require('fs-extra'))
const tmp = Promise.promisifyAll(require('tmp'))
@@ -11,9 +13,12 @@ module.exports = {
},
run (options = {}) {
return tmp.fileAsync().then((outputPath) => {
return tmp.fileAsync()
.then((outputPath) => {
options.outputPath = outputPath
return run.start(options).then(() => {
return run.start(options)
.then(() => {
return fs.readJsonAsync(outputPath)
})
})