This repository has been archived by the owner on Oct 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
/
Cakefile
67 lines (54 loc) · 2.29 KB
/
Cakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
fs = require 'fs'
glob = require 'glob'
path = require 'path'
browserify = require 'browserify'
CoffeeScript = require 'coffeescript'
{ exec } = require 'child_process'
copySync = (src, dest) ->
fs.writeFileSync dest, fs.readFileSync(src)
coffeeSync = (input, output) ->
coffee = fs.readFileSync(input).toString()
fs.writeFileSync output, CoffeeScript.compile(coffee)
task 'compile', 'Compile Coffeelint', ->
console.log 'Compiling Coffeelint...'
fs.mkdirSync 'lib' unless fs.existsSync 'lib'
invoke 'compile:browserify'
invoke 'compile:commandline'
task 'compile:commandline', 'Compiles commandline.js', ->
coffeeSync 'src/commandline.coffee', 'lib/commandline.js'
coffeeSync 'src/configfinder.coffee', 'lib/configfinder.js'
coffeeSync 'src/cache.coffee', 'lib/cache.js'
coffeeSync 'src/ruleLoader.coffee', 'lib/ruleLoader.js'
fs.mkdirSync 'lib/reporters' unless fs.existsSync 'lib/reporters'
for src in glob.sync('reporters/*.coffee', { cwd: 'src' })
# Slice the "coffee" extension of the end and replace with js
dest = src[...-6] + 'js'
coffeeSync "src/#{src}", "lib/#{dest}"
task 'compile:browserify', 'Uses browserify to compile coffeelint', ->
opts =
standalone: 'coffeelint'
b = browserify(opts)
b.add [ './src/coffeelint.coffee' ]
b.transform require('coffeeify')
b.bundle().pipe fs.createWriteStream('lib/coffeelint.js')
task 'prepublish', 'Prepublish', ->
{ npm_config_argv } = process.env
if npm_config_argv? and JSON.parse(npm_config_argv).original[0] is 'install'
return
copySync 'package.json', '.package.json'
packageJson = require './package.json'
delete packageJson.dependencies.browserify
delete packageJson.dependencies.coffeeify
delete packageJson.scripts.install
fs.writeFileSync 'package.json', JSON.stringify(packageJson, undefined, 2)
invoke 'compile'
task 'postpublish', 'Postpublish', ->
# Revert the package.json back to it's original state
exec 'git checkout ./package.json', (err) ->
if err
console.error('Error reverting package.json: ' + err)
task 'publish', 'publish', ->
copySync '.package.json', 'package.json'
task 'install', 'Install', ->
unless require("fs").existsSync("lib/commandline.js")
invoke 'compile'