mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Add initial build task
This commit is contained in:
@@ -1,9 +1,59 @@
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
rm = require('rimraf').sync
|
||||
mkdir = require('wrench').mkdirSyncRecursive
|
||||
cp = require('wrench').copyDirSyncRecursive
|
||||
_ = require 'underscore'
|
||||
CSON = require 'season'
|
||||
|
||||
BUILD_DIR = '/tmp/atom-build'
|
||||
APP_DIR = path.join(BUILD_DIR, 'Atom.app', 'Contents', 'Resources', 'app')
|
||||
|
||||
module.exports = (grunt) ->
|
||||
grunt.initConfig
|
||||
pkg: grunt.file.readJSON('package.json')
|
||||
|
||||
coffee:
|
||||
options:
|
||||
sourceMap: true
|
||||
|
||||
glob_to_multiple:
|
||||
expand: true
|
||||
src: [
|
||||
'src/**/*.coffee'
|
||||
'static/**/*.coffee'
|
||||
'vendor/**/*.coffee'
|
||||
]
|
||||
dest: APP_DIR
|
||||
ext: '.js'
|
||||
|
||||
less:
|
||||
options:
|
||||
paths: [
|
||||
'static'
|
||||
'vendor'
|
||||
]
|
||||
glob_to_multiple:
|
||||
expand: true
|
||||
src: [
|
||||
'src/**/*.less'
|
||||
'static/**/*.less'
|
||||
'themes/**/*.less'
|
||||
]
|
||||
dest: APP_DIR
|
||||
ext: '.css'
|
||||
|
||||
cson:
|
||||
glob_to_multiple:
|
||||
expand: true
|
||||
src: [
|
||||
'src/**/*.cson'
|
||||
'static/**/*.cson'
|
||||
'themes/**/*.cson'
|
||||
]
|
||||
dest: APP_DIR
|
||||
ext: '.json'
|
||||
|
||||
coffeelint:
|
||||
options:
|
||||
max_line_length:
|
||||
@@ -24,9 +74,26 @@ module.exports = (grunt) ->
|
||||
|
||||
grunt.loadNpmTasks('grunt-coffeelint')
|
||||
grunt.loadNpmTasks('grunt-contrib-csslint')
|
||||
grunt.loadNpmTasks('grunt-contrib-coffee')
|
||||
grunt.loadNpmTasks('grunt-contrib-less')
|
||||
|
||||
grunt.registerMultiTask 'cson', 'Compile CSON files to JSON', ->
|
||||
for mapping in @files
|
||||
source = mapping.src[0]
|
||||
destination = mapping.dest
|
||||
try
|
||||
object = CSON.readFileSync(source)
|
||||
if !_.isObject(object) or _.isArray(object)
|
||||
grunt.log.error("#{source} does not contain a root object")
|
||||
return false
|
||||
mkdir path.dirname(destination)
|
||||
CSON.writeFileSync(destination, object)
|
||||
grunt.log.writeln("File #{destination.cyan} created.")
|
||||
catch e
|
||||
grunt.log.error("Parsing #{source} failed: #{e.message}")
|
||||
return false
|
||||
|
||||
grunt.registerTask 'clean', 'Delete all build files', ->
|
||||
rm = require('rimraf').sync
|
||||
rm BUILD_DIR
|
||||
rm '/tmp/atom-coffee-cache'
|
||||
rm '/tmp/atom-cached-atom-shells'
|
||||
@@ -36,5 +103,12 @@ module.exports = (grunt) ->
|
||||
rm 'node'
|
||||
rm 'prebuilt-cef'
|
||||
|
||||
grunt.registerTask 'build', 'Build the application', ->
|
||||
rm BUILD_DIR
|
||||
mkdir BUILD_DIR
|
||||
cp 'atom-shell', path.join(BUILD_DIR, 'atom-shell')
|
||||
grunt.task.run('compile')
|
||||
|
||||
grunt.registerTask('compile', ['coffee', 'less', 'cson'])
|
||||
grunt.registerTask('lint', ['coffeelint', 'csslint'])
|
||||
grunt.registerTask('default', 'lint')
|
||||
grunt.registerTask('default', ['lint', 'build'])
|
||||
|
||||
@@ -66,7 +66,10 @@
|
||||
"grunt-cli": "~0.1.9",
|
||||
"grunt-coffeelint": "0.0.6",
|
||||
"grunt-contrib-csslint": "~0.1.2",
|
||||
"rimraf": "~2.1.4"
|
||||
"rimraf": "~2.1.4",
|
||||
"wrench": "~1.5.1",
|
||||
"grunt-contrib-coffee": "~0.7.0",
|
||||
"grunt-contrib-less": "~0.5.2"
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user