mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Compile bundled package files in compile task
Any .coffee, .cson, and .less files found in bundled Atom packages in node_modules are now compiled during the compile task
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
|
||||
module.exports = (grunt) ->
|
||||
@@ -8,51 +9,65 @@ module.exports = (grunt) ->
|
||||
appDir = path.join(contentsDir, 'Resources', 'app')
|
||||
installDir = path.join('/Applications', appName)
|
||||
|
||||
coffeeConfig =
|
||||
options:
|
||||
sourceMap: true
|
||||
glob_to_multiple:
|
||||
expand: true
|
||||
src: [
|
||||
'src/**/*.coffee'
|
||||
'static/**/*.coffee'
|
||||
]
|
||||
dest: appDir
|
||||
ext: '.js'
|
||||
|
||||
lessConfig =
|
||||
options:
|
||||
paths: [
|
||||
'static'
|
||||
'vendor'
|
||||
]
|
||||
glob_to_multiple:
|
||||
expand: true
|
||||
src: [
|
||||
'src/**/*.less'
|
||||
'static/**/*.less'
|
||||
'themes/**/*.less'
|
||||
]
|
||||
dest: appDir
|
||||
ext: '.css'
|
||||
|
||||
csonConfig =
|
||||
options:
|
||||
rootObject: true
|
||||
glob_to_multiple:
|
||||
expand: true
|
||||
src: [
|
||||
'src/**/*.cson'
|
||||
'static/**/*.cson'
|
||||
'themes/**/*.cson'
|
||||
]
|
||||
dest: appDir
|
||||
ext: '.json'
|
||||
|
||||
for child in fs.readdirSync('node_modules') when child isnt '.bin'
|
||||
directory = path.join('node_modules', child)
|
||||
{engines} = grunt.file.readJSON(path.join(directory, 'package.json'))
|
||||
if engines?.atom?
|
||||
coffeeConfig.glob_to_multiple.src.push("#{directory}/**/*.coffee")
|
||||
lessConfig.glob_to_multiple.src.push("#{directory}/**/*.less")
|
||||
csonConfig.glob_to_multiple.src.push("#{directory}/**/*.cson")
|
||||
|
||||
grunt.initConfig
|
||||
pkg: grunt.file.readJSON('package.json')
|
||||
|
||||
atom: {appDir, appName, buildDir, contentsDir, installDir, shellAppDir}
|
||||
|
||||
coffee:
|
||||
options:
|
||||
sourceMap: true
|
||||
glob_to_multiple:
|
||||
expand: true
|
||||
src: [
|
||||
'src/**/*.coffee'
|
||||
'static/**/*.coffee'
|
||||
]
|
||||
dest: appDir
|
||||
ext: '.js'
|
||||
coffee: coffeeConfig
|
||||
|
||||
less:
|
||||
options:
|
||||
paths: [
|
||||
'static'
|
||||
'vendor'
|
||||
]
|
||||
glob_to_multiple:
|
||||
expand: true
|
||||
src: [
|
||||
'src/**/*.less'
|
||||
'static/**/*.less'
|
||||
'themes/**/*.less'
|
||||
]
|
||||
dest: appDir
|
||||
ext: '.css'
|
||||
less: lessConfig
|
||||
|
||||
cson:
|
||||
options:
|
||||
rootObject: true
|
||||
glob_to_multiple:
|
||||
expand: true
|
||||
src: [
|
||||
'src/**/*.cson'
|
||||
'static/**/*.cson'
|
||||
'themes/**/*.cson'
|
||||
]
|
||||
dest: appDir
|
||||
ext: '.json'
|
||||
cson: csonConfig
|
||||
|
||||
coffeelint:
|
||||
options:
|
||||
|
||||
@@ -18,22 +18,26 @@ module.exports = (grunt) ->
|
||||
cp 'atom.sh', path.join(appDir, 'atom.sh')
|
||||
cp 'package.json', path.join(appDir, 'package.json')
|
||||
|
||||
directories = [
|
||||
packageDirectories = []
|
||||
nonPackageDirectories = [
|
||||
'benchmark'
|
||||
'dot-atom'
|
||||
'spec'
|
||||
'vendor'
|
||||
]
|
||||
|
||||
{devDependencies, dependencies} = grunt.file.readJSON('package.json')
|
||||
{devDependencies} = grunt.file.readJSON('package.json')
|
||||
for child in fs.readdirSync('node_modules')
|
||||
directory = path.join('node_modules', child)
|
||||
try
|
||||
{name} = grunt.file.readJSON(path.join(directory, 'package.json'))
|
||||
if not devDependencies[name]? or dependencies[name]?
|
||||
directories.push(directory)
|
||||
{name, engines} = grunt.file.readJSON(path.join(directory, 'package.json'))
|
||||
continue if devDependencies[name]?
|
||||
if engines?.atom?
|
||||
packageDirectories.push(directory)
|
||||
else
|
||||
nonPackageDirectories.push(directory)
|
||||
catch e
|
||||
directories.push(directory)
|
||||
nonPackageDirectories.push(directory)
|
||||
|
||||
ignoredPaths = [
|
||||
path.join('git-utils', 'deps')
|
||||
@@ -43,8 +47,10 @@ module.exports = (grunt) ->
|
||||
]
|
||||
ignoredPaths = ignoredPaths.map (ignoredPath) -> "(#{ignoredPath})"
|
||||
nodeModulesFilter = new RegExp(ignoredPaths.join('|'))
|
||||
for directory in directories
|
||||
for directory in nonPackageDirectories
|
||||
cp directory, path.join(appDir, directory), filter: nodeModulesFilter
|
||||
for directory in packageDirectories
|
||||
cp directory, path.join(appDir, directory), filter: /.+\.(cson|coffee|less)$/
|
||||
|
||||
cp 'src', path.join(appDir, 'src'), filter: /.+\.(cson|coffee|less)$/
|
||||
cp 'static', path.join(appDir, 'static'), filter: /.+\.less$/
|
||||
|
||||
Reference in New Issue
Block a user