Merge pull request #1118 from atom/cj-less-verbose-grunt

Less verbose grunt
This commit is contained in:
Corey Johnson 2013-11-15 09:05:11 -08:00
commit 941fc97e79
8 changed files with 86 additions and 68 deletions

View File

@ -8,6 +8,10 @@ _ = require 'underscore-plus'
packageJson = require './package.json'
module.exports = (grunt) ->
if not grunt.option('verbose')
grunt.log.writeln = (args...) -> grunt.log
grunt.log.write = (args...) -> grunt.log
[major, minor, patch] = packageJson.version.split('.')
if process.platform is 'win32'
appName = 'Atom'

View File

@ -1,29 +1,28 @@
measure 'spec suite require time', ->
{_, fs, Git} = require 'atom'
path = require 'path'
require './spec-helper'
{_, fs, Git} = require 'atom'
path = require 'path'
require './spec-helper'
requireSpecs = (specDirectory, specType) ->
requireSpecs = (specDirectory, specType) ->
for specFilePath in fs.listTreeSync(specDirectory) when /-spec\.coffee$/.test specFilePath
require specFilePath
# Set spec directory on spec for setting up the project in spec-helper
setSpecDirectory(specDirectory)
setSpecField = (name, value) ->
setSpecField = (name, value) ->
specs = jasmine.getEnv().currentRunner().specs()
return if specs.length is 0
for index in [specs.length-1..0]
break if specs[index][name]?
specs[index][name] = value
setSpecType = (specType) ->
setSpecType = (specType) ->
setSpecField('specType', specType)
setSpecDirectory = (specDirectory) ->
setSpecDirectory = (specDirectory) ->
setSpecField('specDirectory', specDirectory)
runAllSpecs = ->
runAllSpecs = ->
# Only run core specs when resource path is the Atom repository
if Git.exists(window.resourcePath)
requireSpecs(path.join(window.resourcePath, 'spec'))
@ -47,8 +46,8 @@ measure 'spec suite require time', ->
requireSpecs(path.join(packagePath, 'spec')) for packagePath in packagePaths.user ? []
setSpecType('user')
if specDirectory = atom.getLoadSettings().specDirectory
if specDirectory = atom.getLoadSettings().specDirectory
requireSpecs(specDirectory)
setSpecType('user')
else
else
runAllSpecs()

View File

@ -62,7 +62,7 @@ delegate.browserMainParts.preMainMessageLoopRun = ->
AtomApplication = require './atom-application'
AtomApplication.open(args)
console.log("App load time: #{Date.now() - startTime}ms")
console.log("App load time: #{Date.now() - startTime}ms") unless args.test
global.devResourcePath = path.join(app.getHomeDir(), 'github', 'atom')

View File

@ -30,16 +30,16 @@ module.exports = (grunt) ->
themeMains.push(mainPath) if grunt.file.isFile(mainPath)
importPaths.unshift(stylesheetsDir) if grunt.file.isDir(stylesheetsDir)
grunt.log.writeln("Building LESS cache for #{configuration.join(', ').yellow}")
grunt.verbose.writeln("Building LESS cache for #{configuration.join(', ').yellow}")
lessCache = new LessCache
cacheDir: directory
resourcePath: path.resolve('.')
importPaths: importPaths
for file in @filesSrc
grunt.log.writeln("File #{file.cyan} created in cache.")
grunt.verbose.writeln("File #{file.cyan} created in cache.")
lessCache.readFileSync(file)
for file in themeMains
grunt.log.writeln("File #{file.cyan} created in cache.")
grunt.verbose.writeln("File #{file.cyan} created in cache.")
lessCache.readFileSync(file)

View File

@ -84,7 +84,7 @@ module.exports = (grunt) ->
for name, version of packageDependencies
do (name, version) ->
tasks.push (callback) ->
grunt.log.writeln("Publishing #{name}@#{version}")
grunt.verbose.writeln("Publishing #{name}@#{version}")
tag = "v#{version}"
packageExists name, token, (error, exists) ->
if error?

View File

@ -2,6 +2,7 @@ fs = require 'fs'
path = require 'path'
_ = require 'underscore-plus'
async = require 'async'
module.exports = (grunt) ->
@ -10,7 +11,7 @@ module.exports = (grunt) ->
packageSpecQueue = null
runPackageSpecs = (callback) ->
passed = true
failedPackages = []
rootDir = grunt.config.get('atom.shellAppDir')
appDir = grunt.config.get('atom.appDir')
atomPath = path.join(appDir, 'atom.sh')
@ -23,10 +24,10 @@ module.exports = (grunt) ->
opts:
cwd: packagePath
env: _.extend({}, process.env, ATOM_PATH: rootDir)
grunt.log.writeln("Launching #{path.basename(packagePath)} specs.")
grunt.verbose.writeln "Launching #{path.basename(packagePath)} specs."
spawn options, (error, results, code) ->
grunt.log.writeln()
passed = passed and not error and code is 0
failedPackages.push path.basename(packagePath) if error
callback()
modulesDirectory = path.resolve('node_modules')
@ -37,7 +38,7 @@ module.exports = (grunt) ->
packageSpecQueue.push(packagePath)
packageSpecQueue.concurrency = 1
packageSpecQueue.drain = -> callback(null, passed)
packageSpecQueue.drain = -> callback(null, failedPackages)
runCoreSpecs = (callback) ->
contentsDir = grunt.config.get('atom.contentsDir')
@ -49,15 +50,20 @@ module.exports = (grunt) ->
cmd: appPath
args: ['--test', "--resource-path=#{resourcePath}", "--spec-directory=#{coreSpecsPath}"]
spawn options, (error, results, code) ->
grunt.log.writeln()
packageSpecQueue.concurrency = 2
callback(null, not error and code is 0)
callback(null, error)
grunt.registerTask 'run-specs', 'Run the specs', ->
done = @async()
startTime = Date.now()
async.parallel [runCoreSpecs, runPackageSpecs], (error, results) ->
[coreSpecPassed, packageSpecsPassed] = results
[coreSpecFailed, failedPackages] = results
elapsedTime = Math.round((Date.now() - startTime) / 100) / 10
grunt.log.writeln("Total spec time: #{elapsedTime}s")
done(coreSpecPassed and packageSpecsPassed)
grunt.verbose.writeln("Total spec time: #{elapsedTime}s")
failures = failedPackages
failures.push "atom core" if coreSpecFailed
grunt.log.error("[Error]".red + " #{failures.join(', ')} spec(s) failed") if failures.length > 0
done(!coreSpecFailed and failedPackages.length == 0)

View File

@ -23,7 +23,7 @@ module.exports = (grunt) ->
catch error
grunt.fatal(error)
grunt.log.writeln("Copied #{source.cyan} to #{destination.cyan}.")
grunt.verbose.writeln("Copied #{source.cyan} to #{destination.cyan}.")
mkdir: (args...) ->
grunt.file.mkdir(args...)
@ -32,9 +32,18 @@ module.exports = (grunt) ->
grunt.file.delete(args..., force: true) if grunt.file.exists(args...)
spawn: (options, callback) ->
grunt.util.spawn options, (error, results, code) ->
grunt.log.errorlns results.stderr if results.stderr
callback(error, results, code)
childProcess = require 'child_process'
stdout = []
stderr = []
error = null
proc = childProcess.spawn(options.cmd, options.args, options.opts)
proc.stdout.on 'data', (data) -> stdout.push(data.toString())
proc.stderr.on 'data', (data) -> stderr.push(data.toString())
proc.on 'exit', (exitCode, signal) ->
error = new Error(signal) if exitCode != 0
results = {stderr: stderr.join(''), stdout: stdout.join(''), code: exitCode}
grunt.log.error results.stderr if exitCode != 0
callback(error, results, exitCode)
isAtomPackage: (packagePath) ->
try

View File

@ -112,7 +112,7 @@ module.exports = (grunt) ->
# Manually handle redirection so headers would not be sent for S3.
downloadAtomShell(version, response.headers.location, callback)
else if response.statusCode is 200
grunt.log.writeln("Downloading atom-shell version #{version.cyan}")
grunt.verbose.writeln("Downloading atom-shell version #{version.cyan}")
cacheDirectory = getCachePath(version)
rm(cacheDirectory)
mkdir(cacheDirectory)
@ -146,7 +146,7 @@ module.exports = (grunt) ->
downloadAtomShell version, url, callback
unzipAtomShell = (zipPath, callback) ->
grunt.log.writeln('Unzipping atom-shell')
grunt.verbose.writeln('Unzipping atom-shell')
directoryPath = path.dirname(zipPath)
if process.platform is 'darwin'
@ -167,7 +167,7 @@ module.exports = (grunt) ->
rebuildNativeModules = (previousVersion, callback) ->
newVersion = getAtomShellVersion()
if newVersion and newVersion isnt previousVersion
grunt.log.writeln("Rebuilding native modules for new atom-shell version #{newVersion.cyan}.")
grunt.verbose.writeln("Rebuilding native modules for new atom-shell version #{newVersion.cyan}.")
cmd = path.join('node_modules', '.bin', 'apm')
cmd += ".cmd" if process.platform is 'win32'
spawn {cmd, args: ['rebuild']}, (error) -> callback(error)
@ -186,7 +186,7 @@ module.exports = (grunt) ->
currentAtomShellVersion = getAtomShellVersion()
if atomShellVersion isnt currentAtomShellVersion
if isAtomShellVersionCached(atomShellVersion)
grunt.log.writeln("Installing cached atom-shell #{atomShellVersion.cyan}")
grunt.verbose.writeln("Installing cached atom-shell #{atomShellVersion.cyan}")
installAtomShell(atomShellVersion)
rebuildNativeModules(currentAtomShellVersion, done)
else
@ -198,7 +198,7 @@ module.exports = (grunt) ->
if error?
done(error)
else
grunt.log.writeln("Installing atom-shell #{atomShellVersion.cyan}")
grunt.verbose.writeln("Installing atom-shell #{atomShellVersion.cyan}")
installAtomShell(atomShellVersion)
rebuildNativeModules(currentAtomShellVersion, done)
else