mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Decouple "mkdirp"
Make coffee completely independent.
This commit is contained in:
@@ -13,8 +13,6 @@
|
||||
|
||||
CoffeeScript = require('./coffee-script');
|
||||
|
||||
mkdirp = require('mkdirp');
|
||||
|
||||
_ref = require('child_process'), spawn = _ref.spawn, exec = _ref.exec;
|
||||
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
@@ -440,6 +438,27 @@
|
||||
return path.join(dir, basename + extension);
|
||||
};
|
||||
|
||||
mkdirp = function(dir, fn) {
|
||||
var mkdirs, mode;
|
||||
mode = 0x1ff & ~process.umask();
|
||||
return (mkdirs = function(p, fn) {
|
||||
return fs.exists(p, function(exists) {
|
||||
if (exists) {
|
||||
return fn();
|
||||
} else {
|
||||
return mkdirs(path.dirname(p), function() {
|
||||
return fs.mkdir(p, mode, function(err) {
|
||||
if (err) {
|
||||
return fn(err);
|
||||
}
|
||||
return fn();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
})(dir, fn);
|
||||
};
|
||||
|
||||
writeJs = function(base, sourcePath, js, jsPath, generatedSourceMap) {
|
||||
var compile, jsDir, sourceMapPath;
|
||||
if (generatedSourceMap == null) {
|
||||
|
||||
@@ -38,8 +38,5 @@
|
||||
"highlight.js": "~8.0.0",
|
||||
"underscore": "~1.5.2",
|
||||
"docco": "~0.6.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"mkdirp": "~0.3.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ path = require 'path'
|
||||
helpers = require './helpers'
|
||||
optparse = require './optparse'
|
||||
CoffeeScript = require './coffee-script'
|
||||
mkdirp = require 'mkdirp'
|
||||
{spawn, exec} = require 'child_process'
|
||||
{EventEmitter} = require 'events'
|
||||
|
||||
@@ -330,6 +329,20 @@ outputPath = (source, base, extension=".js") ->
|
||||
dir = path.join opts.output, path.relative base, srcDir
|
||||
path.join dir, basename + extension
|
||||
|
||||
# Recursively mkdir, like `mkdir -p`.
|
||||
mkdirp = (dir, fn) ->
|
||||
mode = 0o777 & ~process.umask()
|
||||
|
||||
do mkdirs = (p = dir, fn) ->
|
||||
fs.exists p, (exists) ->
|
||||
if exists
|
||||
fn()
|
||||
else
|
||||
mkdirs path.dirname(p), ->
|
||||
fs.mkdir p, mode, (err) ->
|
||||
return fn err if err
|
||||
fn()
|
||||
|
||||
# Write out a JavaScript source file with the compiled code. By default, files
|
||||
# are written out in `cwd` as `.js` files with the same name, but the output
|
||||
# directory can be customized with `--output`.
|
||||
|
||||
Reference in New Issue
Block a user