fix(specs): Remove promise usage, process.env as fn to fix node 0.10

This commit is contained in:
Ben Gotow 2015-11-30 12:39:17 -08:00
parent f66f503a75
commit 734e670e81

View file

@ -1,7 +1,6 @@
fs = require 'fs' fs = require 'fs'
path = require 'path' path = require 'path'
request = require 'request' request = require 'request'
Promise = require 'bluebird'
childProcess = require 'child_process' childProcess = require 'child_process'
executeTests = ({cmd, args}, grunt, done) -> executeTests = ({cmd, args}, grunt, done) ->
@ -16,22 +15,31 @@ executeTests = ({cmd, args}, grunt, done) ->
testProc.on 'error', (err) -> grunt.log.error("Process error: #{err}") testProc.on 'error', (err) -> grunt.log.error("Process error: #{err}")
testProc.on 'exit', (exitCode, signal) -> testProc.on 'exit', (exitCode, signal) ->
if exitCode is 0 then done() if exitCode is 0
else notifyOfTestError(testOutput, grunt).then -> done(false) done()
else
notifyOfTestError testOutput, grunt, ->
done(false)
notifyOfTestError = (testOutput, grunt) -> new Promise (resolve, reject) -> notifyOfTestError = (testOutput, grunt, callback) ->
if (process.env("TEST_ERROR_HOOK_URL") ? "").length > 0 if (process.env["TEST_ERROR_HOOK_URL"] ? "").length > 0
testOutput = grunt.log.uncolor(testOutput) testOutput = grunt.log.uncolor(testOutput)
request.post request.post
url: process.env("TEST_ERROR_HOOK_URL") url: process.env["TEST_ERROR_HOOK_URL"]
json: json:
username: "Edgehill Builds" username: "Edgehill Builds"
text: "Aghhh somebody broke the build. ```#{testOutput}```" text: "Aghhh somebody broke the build. ```#{testOutput}```"
, resolve , callback
else resolve() else
callback()
module.exports = (grunt) -> module.exports = (grunt) ->
grunt.registerTask 'run-edgehill-specs', 'Run the specs', ->
done = @async()
executeTests({cmd: './N1.sh', args: ['--test']}, grunt, done)
grunt.registerTask 'run-spectron-specs', 'Run spectron specs', -> grunt.registerTask 'run-spectron-specs', 'Run spectron specs', ->
shellAppDir = grunt.config.get('nylasGruntConfig.shellAppDir') shellAppDir = grunt.config.get('nylasGruntConfig.shellAppDir')
@ -65,11 +73,6 @@ module.exports = (grunt) ->
"APP_PATH=#{executablePath}" "APP_PATH=#{executablePath}"
"APP_ARGS=" "APP_ARGS="
] ]
executeTests cmd: npmPath, args: appArgs, grunt, (succeeded) -> executeTests {cmd: npmPath, args: appArgs}, grunt, (succeeded) ->
process.chdir('..') process.chdir('..')
done(succeeded) done(succeeded)
grunt.registerTask 'run-edgehill-specs', 'Run the specs', ->
done = @async()
executeTests cmd: './N1.sh', args: ['--test'], grunt, done