Updating fs module to the latest Node.js -- that's fs.readFile, not fs.cat, with string flags for fs.open

This commit is contained in:
Jeremy Ashkenas 2010-02-17 08:51:27 -05:00
parent 0490cb2920
commit dfa63839bb
5 changed files with 10 additions and 10 deletions

View File

@ -27,7 +27,7 @@ task 'build:parser', 'rebuild the Jison parser', ->
parser: require('grammar').parser
js: parser.generate()
parser_path: 'lib/parser.js'
fs.open(parser_path, process.O_CREAT | process.O_WRONLY | process.O_TRUNC, parseInt('0755', 8)).addCallback (fd) ->
fs.open(parser_path, 'w+', 0755).addCallback (fd) ->
fs.write(fd, js)
@ -54,6 +54,6 @@ task 'test', 'run the CoffeeScript language test suite', ->
puts '\033[0;32mpassed ' + test_count + ' tests in ' + time + ' seconds\033[0m'
fs.readdir('test').addCallback (files) ->
for file in files
fs.cat('test/' + file).addCallback (source) ->
fs.readFile('test/' + file).addCallback (source) ->
js: coffee.compile source
process.compile js, file

View File

@ -50,7 +50,7 @@
throw new Error('Cakefile not found in ' + process.cwd());
}
args = process.ARGV.slice(2, process.ARGV.length);
return fs.cat('Cakefile').addCallback(function(source) {
return fs.readFile('Cakefile').addCallback(function(source) {
var _a, _b, _c, arg;
eval(coffee.compile(source));
if (!(args.length)) {

View File

@ -72,7 +72,7 @@
if (!((source = sources.shift()))) {
return null;
}
return fs.cat(source).addCallback(function(code) {
return fs.readFile(source).addCallback(function(code) {
compile_script(source, code);
return compile_scripts();
});
@ -121,7 +121,7 @@
if (curr.mtime.getTime() === prev.mtime.getTime()) {
return null;
}
return fs.cat(source).addCallback(function(code) {
return fs.readFile(source).addCallback(function(code) {
return compile_script(source, code);
});
}));
@ -134,7 +134,7 @@
filename = path.basename(source, path.extname(source)) + '.js';
dir = options.output || path.dirname(source);
js_path = path.join(dir, filename);
return fs.open(js_path, process.O_CREAT | process.O_WRONLY | process.O_TRUNC, parseInt('0755', 8)).addCallback(function(fd) {
return fs.open(js_path, 'w+', 0755).addCallback(function(fd) {
return fs.write(fd, js);
});
};

View File

@ -31,7 +31,7 @@ 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.cat('Cakefile').addCallback (source) ->
fs.readFile('Cakefile').addCallback (source) ->
eval coffee.compile source
return print_tasks() unless args.length
for arg in args

View File

@ -71,7 +71,7 @@ compile: (script, source) ->
# or JSLint results.
compile_scripts: ->
return unless source: sources.shift()
fs.cat(source).addCallback (code) ->
fs.readFile(source).addCallback (code) ->
compile_script(source, code)
compile_scripts()
@ -97,7 +97,7 @@ watch_scripts: ->
for source in sources
process.watchFile source, {persistent: true, interval: 500}, (curr, prev) ->
return if curr.mtime.getTime() is prev.mtime.getTime()
fs.cat(source).addCallback (code) -> compile_script(source, code)
fs.readFile(source).addCallback (code) -> compile_script(source, code)
# Write out a JavaScript source file with the compiled code.
@ -105,7 +105,7 @@ write_js: (source, js) ->
filename: path.basename(source, path.extname(source)) + '.js'
dir: options.output or path.dirname(source)
js_path: path.join dir, filename
fs.open(js_path, process.O_CREAT | process.O_WRONLY | process.O_TRUNC, parseInt('0755', 8)).addCallback (fd) ->
fs.open(js_path, 'w+', 0755).addCallback (fd) ->
fs.write(fd, js)
# Pipe compiled JS through JSLint (requires a working 'jsl' command).