Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "dawn-js", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A no config e2e test runner", | ||
@@ -9,2 +9,5 @@ "main": "index.js", | ||
"license": "MIT", | ||
"bin": { | ||
"dawn": "./bin/dawn" | ||
}, | ||
"dependencies": { | ||
@@ -11,0 +14,0 @@ "babel-register": "^6.24.0", |
@@ -78,5 +78,5 @@ require('babel-register') | ||
if (project('nightwatch.conf.js')) { | ||
if (project('nightwatch.conf.js', true)) { | ||
const merge = require('deepmerge') | ||
module.exports = merge(module.exports, require(project('nightwatch.conf.js'))) | ||
} |
@@ -7,7 +7,14 @@ /* | ||
*/ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const merge = require('deepmerge') | ||
const project = (any) => path.resolve(process.cwd(), any) | ||
const project = (any, shouldExist = false) => { | ||
const filename = path.join(process.cwd(), any) | ||
if (shouldExist && !fs.existsSync(filename)) return null | ||
return filename | ||
} | ||
const logger = require('debug')( | ||
@@ -28,3 +35,3 @@ (require(project('package.json')) || {}).name || 'dusk' | ||
if (project('dawn.config.js')) { | ||
if (project('dawn.config.js', true)) { | ||
const user = require(project('dawn.config.js')) | ||
@@ -31,0 +38,0 @@ |
@@ -19,3 +19,3 @@ /* | ||
*/ | ||
const path = project('.env') | ||
const env_file = project('.env') | ||
@@ -28,3 +28,5 @@ /** | ||
const use = function (name) { | ||
fs.writeFileSync(exports.path, fs.readFileSync(exports.path + '.' + name)) | ||
if (project(`.env.dawn.${name}`, true)) { | ||
fs.writeFileSync(exports.path, fs.readFileSync(project(`.env.dawn.${name}`))) | ||
} | ||
} | ||
@@ -36,9 +38,11 @@ | ||
const cleanup = function cleanup() { | ||
fs.writeFileSync(exports.path, fs.readFileSync(backup)) | ||
fs.unlinkSync(backup) | ||
if (fs.existsSync(backup)) { | ||
fs.writeFileSync(env_file, fs.readFileSync(backup).toString()) | ||
fs.unlinkSync(backup) | ||
} | ||
} | ||
// Backup .env file. | ||
fs.writeFileSync(backup, exports.get()) | ||
fs.writeFileSync(backup, fs.readFileSync(env_file).toString()) | ||
module.exports = { path, backup, use, cleanup } | ||
module.exports = { path: env_file, backup, use, cleanup } |
@@ -21,4 +21,12 @@ process.env.NODE_ENV = 'testing' | ||
config.logger('Start NightWatch!') | ||
const binary = config.project('node_modules/.bin/nightwatch', true) | ||
if (!binary) { | ||
console.log('NightWatch is not installed. Run: yarn add --dev nightwatch') | ||
throw new Error() | ||
} | ||
const tests = spawn( | ||
config.project('node_modules/.bin/nightwatch'), | ||
binary, | ||
[ | ||
@@ -25,0 +33,0 @@ '--config', path.resolve(__dirname, '../setup/nightwatch.conf.js'), |
@@ -13,7 +13,13 @@ /* | ||
function serve(resolve, reject) { | ||
function start({ serve }, resolve, reject) { | ||
let started = false | ||
if (!config.laravel.serve) return resolve() // No need to serve. | ||
if (!serve) { | ||
log('No need for laravel serve.') | ||
return resolve() | ||
} // No need to serve. | ||
log('Starting laravel server...') | ||
const laravel = spawn('php', | ||
@@ -37,2 +43,3 @@ ['artisan', 'serve', `--host=${config.laravel.host}`, `--port=${config.laravel.port}`], | ||
started = true | ||
console.log(`Started Laravel Server: ${config.laravel.host}:${config.laravel.port}`) | ||
resolve(laravel) | ||
@@ -45,2 +52,2 @@ }) | ||
*/ | ||
exports.start = () => new Promise(serve) | ||
exports.start = (serve) => new Promise((resolve, reject) => start({ serve }, resolve, reject)) |
Sorry, the diff of this file is not supported yet
82701
27
292
9