mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
40 lines
1.3 KiB
CoffeeScript
40 lines
1.3 KiB
CoffeeScript
fs = require 'fs'
|
|
path = require 'path'
|
|
|
|
_ = require 'underscore'
|
|
async = require 'async'
|
|
|
|
module.exports = (grunt) ->
|
|
{spawn} = require('./task-helpers')(grunt)
|
|
|
|
grunt.registerTask 'run-specs', 'Run the specs', ->
|
|
passed = true
|
|
done = @async()
|
|
appDir = grunt.config.get('atom.appDir')
|
|
rootDir = grunt.config.get('atom.shellAppDir')
|
|
atomPath = path.join(appDir, 'atom.sh')
|
|
apmPath = path.join(appDir, 'node_modules/.bin/apm')
|
|
|
|
queue = async.queue (packagePath, callback) ->
|
|
options =
|
|
cmd: apmPath
|
|
args: ['test', '--path', atomPath]
|
|
opts:
|
|
cwd: packagePath
|
|
env: _.extend({}, process.env, ATOM_PATH: rootDir)
|
|
grunt.log.writeln("Launching #{path.basename(packagePath)} specs.")
|
|
spawn options, (error, results, code) ->
|
|
passed = passed and code is 0
|
|
callback()
|
|
|
|
modulesDirectory = path.resolve('node_modules')
|
|
for packageDirectory in fs.readdirSync(modulesDirectory)
|
|
packagePath = path.join(modulesDirectory, packageDirectory)
|
|
continue unless grunt.file.isDir(path.join(packagePath, 'spec'))
|
|
try
|
|
{engines} = grunt.file.readJSON(path.join(packagePath, 'package.json')) ? {}
|
|
queue.push(packagePath) if engines.atom?
|
|
|
|
queue.concurrency = 1
|
|
queue.drain = -> done(passed)
|