mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
moving some of the fs methods over to sync methods, where it's alright and where it makes things clearer
This commit is contained in:
parent
17ea48c543
commit
5c7526a741
3 changed files with 22 additions and 26 deletions
8
Cakefile
8
Cakefile
|
@ -7,7 +7,7 @@ run: (args) ->
|
|||
proc.addListener 'error', (err) -> if err then puts err
|
||||
|
||||
|
||||
option '-p', '--prefix', 'set the installation prefix for `cake install`'
|
||||
option '-p', '--prefix [DIR]', 'set the installation prefix for `cake install`'
|
||||
|
||||
task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options) ->
|
||||
base: options.prefix or '/usr/local'
|
||||
|
@ -21,9 +21,9 @@ task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options)
|
|||
|
||||
|
||||
task 'build', 'build the CoffeeScript language from source', ->
|
||||
fs.readdir 'src', (err, files) ->
|
||||
files: 'src/' + file for file in files when file.match(/\.coffee$/)
|
||||
run ['-o', 'lib'].concat(files)
|
||||
files: fs.readdirSync 'src'
|
||||
files: 'src/' + file for file in files when file.match(/\.coffee$/)
|
||||
run ['-o', 'lib'].concat(files)
|
||||
|
||||
|
||||
task 'build:parser', 'rebuild the Jison parser (run build first)', ->
|
||||
|
|
29
lib/cake.js
29
lib/cake.js
|
@ -38,26 +38,23 @@
|
|||
// prints them out, with no arguments.
|
||||
exports.run = function run() {
|
||||
return path.exists('Cakefile', function(exists) {
|
||||
var args;
|
||||
var _a, _b, _c, arg, args;
|
||||
if (!(exists)) {
|
||||
throw new Error('Cakefile not found in ' + process.cwd());
|
||||
}
|
||||
args = process.ARGV.slice(2, process.ARGV.length);
|
||||
return fs.readFile('Cakefile', function(err, source) {
|
||||
var _a, _b, _c, arg;
|
||||
eval(coffee.compile(source));
|
||||
oparse = new optparse.OptionParser(switches);
|
||||
if (!(args.length)) {
|
||||
return print_tasks();
|
||||
}
|
||||
options = oparse.parse(args);
|
||||
_a = []; _b = options.arguments;
|
||||
for (_c = 0; _c < _b.length; _c++) {
|
||||
arg = _b[_c];
|
||||
_a.push(invoke(arg));
|
||||
}
|
||||
return _a;
|
||||
});
|
||||
eval(coffee.compile(fs.readFileSync('Cakefile')));
|
||||
oparse = new optparse.OptionParser(switches);
|
||||
if (!(args.length)) {
|
||||
return print_tasks();
|
||||
}
|
||||
options = oparse.parse(args);
|
||||
_a = []; _b = options.arguments;
|
||||
for (_c = 0; _c < _b.length; _c++) {
|
||||
arg = _b[_c];
|
||||
_a.push(invoke(arg));
|
||||
}
|
||||
return _a;
|
||||
});
|
||||
};
|
||||
// Display the list of Cake tasks.
|
||||
|
|
|
@ -36,12 +36,11 @@ exports.run: ->
|
|||
path.exists 'Cakefile', (exists) ->
|
||||
throw new Error('Cakefile not found in ' + process.cwd()) unless exists
|
||||
args: process.ARGV[2...process.ARGV.length]
|
||||
fs.readFile 'Cakefile', (err, source) ->
|
||||
eval coffee.compile source
|
||||
oparse: new optparse.OptionParser switches
|
||||
return print_tasks() unless args.length
|
||||
options: oparse.parse(args)
|
||||
invoke arg for arg in options.arguments
|
||||
eval coffee.compile fs.readFileSync 'Cakefile'
|
||||
oparse: new optparse.OptionParser switches
|
||||
return print_tasks() unless args.length
|
||||
options: oparse.parse(args)
|
||||
invoke arg for arg in options.arguments
|
||||
|
||||
# Display the list of Cake tasks.
|
||||
print_tasks: ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue