Added vendor directory & gulp support for better dependency organization + compiling less & js files. added gulp

support for a browser sync task as well for easier development
This commit is contained in:
billz
2018-03-09 02:03:53 +00:00
parent 659e21f00b
commit 902281294f
10728 changed files with 1157694 additions and 108542 deletions

49
node_modules/gulp-less/Changelog.md generated vendored Normal file
View File

@@ -0,0 +1,49 @@
### 3.2.0
* Update package.json to skip the problematic 2.7.0 release of less. Use 2.6.x or 2.7.1 instead
* bump dependencies on accord, mocha and should
### 3.1.0
* Upgrade accord dependency
* remove CSS minifier recommendation from README
* Upgrade Less dependency from 2.5.1 to 2.6.0
### 3.0.5
* BugFix: fix dynamic imports broken in the 3.0.4 release
### 3.0.4
* Fix the error passing in the stream (#198)
* Update dependencies
### 3.0.3
* Make sourcemap file and sources relative (#161)
### 3.0.2
* Upgrade Less to 2.4.0 (#157)
### 3.0.1
- Bumped accord version to 0.15.1 to fix #122
### 3.0.0
- Switch to using [accord](https://github.com/jenius/accord) for options parsing
### 2.0.3
- Fix less errors by using promises correctly
- Fix option merging, object.assign was used incorrectly
### 2.0.1
Revert moving the replaceExt to after sourcemaps are applied
### 2.0.0
Update to Less 2.0

120
node_modules/gulp-less/README.md generated vendored Normal file
View File

@@ -0,0 +1,120 @@
# gulp-less
> A [LESS](http://lesscss.org/) plugin for Gulp
[![NPM Version](https://img.shields.io/npm/v/gulp-less.svg)](https://www.npmjs.com/package/gulp-less)
[![Build Status](https://img.shields.io/travis/stevelacy/gulp-less.svg)](https://travis-ci.org/stevelacy/gulp-less)
## Information
<table>
<tr>
<td>Package</td><td>gulp-less</td>
</tr>
<tr>
<td>Description</td>
<td>Less plugin for gulp</td>
</tr>
<tr>
<td>Node Version</td>
<td>>= 0.10</td>
</tr>
<tr>
<td>Less Version</td>
<td>>= 2.x</td>
</tr>
<tr>
<td>Gulp Version</td>
<td>3.x</td>
</tr>
</table>
## Installation
```
npm install gulp-less
```
## Basic Usage
```js
var less = require('gulp-less');
var path = require('path');
gulp.task('less', function () {
return gulp.src('./less/**/*.less')
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(gulp.dest('./public/css'));
});
```
## Options
The options you can use [can be found here](http://lesscss.org/#using-less-configuration). Below is a list of valid options as of the time of writing:
- `paths`: Array of paths to be used for `@import` directives
- `plugins`: Array of less plugins ([details](#using-plugins))
The `filename` option is not necessary, it's handled automatically by this plugin. The `compress` option is not supported -- if you are trying to minify your css, use a css minifier. No `sourceMap` options are supported -- if you are trying to generate sourcemaps, use [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps).
## Using Plugins
Less now supports plugins, which can add additional functionality. Here's an example of how to use a plugin with `gulp-less`.
```js
var LessAutoprefix = require('less-plugin-autoprefix');
var autoprefix = new LessAutoprefix({ browsers: ['last 2 versions'] });
return gulp.src('./less/**/*.less')
.pipe(less({
plugins: [autoprefix]
}))
.pipe(gulp.dest('./public/css'));
```
More info on LESS plugins can be found at http://lesscss.org/usage/#plugins, including a current list of all available plugins.
## Source Maps
`gulp-less` can be used in tandem with [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) to generate source maps for your files. You will need to initialize [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) prior to running the gulp-less compiler and write the source maps after, as such:
```js
var sourcemaps = require('gulp-sourcemaps');
gulp.src('./less/**/*.less')
.pipe(sourcemaps.init())
.pipe(less())
.pipe(sourcemaps.write())
.pipe(gulp.dest('./public/css'));
```
By default, [gulp-sourcemaps](https://github.com/floridoo/gulp-sourcemaps) writes the source maps inline in the compiled CSS files. To write them to a separate file, specify a relative file path in the `sourcemaps.write()` function, as such:
```js
var sourcemaps = require('gulp-sourcemaps');
gulp.src('./less/**/*.less')
.pipe(sourcemaps.init())
.pipe(less())
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./public/css'));
```
## Error Handling
By default, a gulp task will fail and all streams will halt when an error happens. To change this behavior check out the error handling documentation [here](https://github.com/gulpjs/gulp/blob/master/docs/recipes/combining-streams-to-handle-errors.md)
## License
(MIT License)
Copyright (c) 2015 Plus 3 Network dev@plus3network.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

61
node_modules/gulp-less/index.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
var path = require('path');
var accord = require('accord');
var through2 = require('through2');
var replaceExt = require('replace-ext');
var assign = require('object-assign');
var applySourceMap = require('vinyl-sourcemaps-apply');
var PluginError = require('plugin-error');
var less = accord.load('less');
module.exports = function (options) {
// Mixes in default options.
var opts = assign({}, {
compress: false,
paths: []
}, options);
return through2.obj(function(file, enc, cb) {
if (file.isNull()) {
return cb(null, file);
}
if (file.isStream()) {
return cb(new PluginError('gulp-less', 'Streaming not supported'));
}
var str = file.contents.toString();
// Injects the path of the current file
opts.filename = file.path;
// Bootstrap source maps
if (file.sourceMap) {
opts.sourcemap = true;
}
less.render(str, opts).then(function(res) {
file.contents = new Buffer(res.result);
file.path = replaceExt(file.path, '.css');
if (res.sourcemap) {
res.sourcemap.file = file.relative;
res.sourcemap.sources = res.sourcemap.sources.map(function (source) {
return path.relative(file.base, source);
});
applySourceMap(file, res.sourcemap);
}
return file;
}).then(function(file) {
cb(null, file);
}).catch(function(err) {
// Convert the keys so PluginError can read them
err.lineNumber = err.line;
err.fileName = err.filename;
// Add a better error message
err.message = err.message + ' in file ' + err.fileName + ' line no. ' + err.lineNumber;
return cb(new PluginError('gulp-less', err));
});
});
};

1
node_modules/gulp-less/node_modules/.bin/lessc generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../less/bin/lessc

View File

@@ -0,0 +1,11 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

View File

@@ -0,0 +1,20 @@
Contributing
------------
Anything that people should know before filing issues or opening pull requests should be here. This is a good place to put details on coding conventions, how to build the project, and how to run tests.
### Filing Issues
If you have found an issue with this library, please let us know! Make sure that before you file an issue, you have searched to see if someone else has already opened it. When opening the issue, make sure there's a clear and concise title and description, and that the description contains specific steps that can be followed to reproduce the issue you are experiencing. Following these guidelines will get your issue fixed up the quickest!
If you are making a feature request, that is welcome in the issues section as well. Make sure again that the title and issue summary are clear so that we can understand what you're asking for. Any use cases would also help. And if you are requesting a feature and are able to work with javscript code, please consider submitting a pull request for the feature!
### Pull Requests
When submitting a pull request, make sure that the code follows the general style and structure elsewhere in the library, that your commit messages are [well-formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), and that you have added tests for whatever feature you are adding.
### Running Tests
To run tests, make sure you have `npm install`ed, then just run `mocha` in the root. If you'd like to run tests just for one specific adapter, you can use mocha's grep option, like this `mocha -g jade` - this would run just the jade test suite.
The way tests are set up is fairly simple, a folder in `fixtures` and a `describe` block for each adapter. All tests are currently compared to expected output through an pure javascript AST, to ensure compatibility across systems.

View File

@@ -0,0 +1,279 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, W, clone, fs, partialRight, path, readFile, requireEngine, resolve, resolvePath,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
W = require('when');
clone = require('lodash.clone');
partialRight = require('lodash.partialright');
resolve = require('resolve');
path = require('path');
fs = require('fs');
readFile = require('when/node/function').lift(fs.readFile);
Adapter = (function() {
/**
* The names of the npm modules that are supported to be used as engines by
the adapter. Defaults to the name of the adapter.
* @type {String[]}
*/
Adapter.prototype.supportedEngines = void 0;
/**
* The name of the engine in-use. Generally this is the name of the package on
npm.
* @type {String}
*/
Adapter.prototype.engineName = '';
/**
* The actual engine, no adapter wrapper. Defaults to the engine that we
recommend for compiling that particular language (if it is installed).
Otherwise, whatever engine we support that is installed.
*/
Adapter.prototype.engine = void 0;
/**
* Array of all file extensions the compiler should match
* @type {String[]}
*/
Adapter.prototype.extensions = void 0;
/**
* Expected output extension
* @type {String}
*/
Adapter.prototype.output = '';
/**
* Specify if the output of the language is independent of other files or the
evaluation of potentially stateful functions. This means that the only
information passed into the engine is what gets passed to Accord's
compile/render function, and whenever that same input is given, the output
will always be the same.
* @type {Boolean}
* @todo Add detection for when a particular job qualifies as isolated
*/
Adapter.prototype.isolated = false;
/**
* @param {String} [engine=Adapter.supportedEngines[0]] If you need to use a
particular engine to compile/render with, then specify it here. Otherwise
we use whatever engine you have installed.
*/
function Adapter(engineName1, customPath) {
var i, len, ref, ref1;
this.engineName = engineName1;
if (!this.supportedEngines || this.supportedEngines.length === 0) {
this.supportedEngines = [this.name];
}
if (this.engineName != null) {
if (ref = this.engineName, indexOf.call(this.supportedEngines, ref) < 0) {
throw new Error("engine '" + this.engineName + "' not supported");
}
this.engine = requireEngine(this.engineName, customPath);
} else {
ref1 = this.supportedEngines;
for (i = 0, len = ref1.length; i < len; i++) {
this.engineName = ref1[i];
try {
this.engine = requireEngine(this.engineName, customPath);
} catch (error) {
continue;
}
return;
}
throw new Error("'tried to require: " + this.supportedEngines + "'.\nNone found. Make sure one has been installed!");
}
}
/**
* Render a string to a compiled string
* @param {String} str
* @param {Object} [opts = {}]
* @return {Promise}
*/
Adapter.prototype.render = function(str, opts) {
if (opts == null) {
opts = {};
}
if (!this._render) {
return W.reject(new Error('render not supported'));
}
return this._render(str, opts);
};
/**
* Render a file to a compiled string
* @param {String} file The path to the file
* @param {Object} [opts = {}]
* @return {Promise}
*/
Adapter.prototype.renderFile = function(file, opts) {
if (opts == null) {
opts = {};
}
opts = clone(opts, true);
return readFile(file, 'utf8').then(partialRight(this.render, Object.assign({
filename: file
}, opts)).bind(this));
};
/**
* Compile a string to a function
* @param {String} str
* @param {Object} [opts = {}]
* @return {Promise}
*/
Adapter.prototype.compile = function(str, opts) {
if (opts == null) {
opts = {};
}
if (!this._compile) {
return W.reject(new Error('compile not supported'));
}
return this._compile(str, opts);
};
/**
* Compile a file to a function
* @param {String} file The path to the file
* @param {Object} [opts = {}]
* @return {Promise}
*/
Adapter.prototype.compileFile = function(file, opts) {
if (opts == null) {
opts = {};
}
return readFile(file, 'utf8').then(partialRight(this.compile, Object.assign({
filename: file
}, opts)).bind(this));
};
/**
* Compile a string to a client-side-ready function
* @param {String} str
* @param {Object} [opts = {}]
* @return {Promise}
*/
Adapter.prototype.compileClient = function(str, opts) {
if (opts == null) {
opts = {};
}
if (!this._compileClient) {
return W.reject(new Error('client-side compile not supported'));
}
return this._compileClient(str, opts);
};
/**
* Compile a file to a client-side-ready function
* @param {String} file The path to the file
* @param {Object} [opts = {}]
* @return {Promise}
*/
Adapter.prototype.compileFileClient = function(file, opts) {
if (opts == null) {
opts = {};
}
return readFile(file, 'utf8').then(partialRight(this.compileClient, Object.assign(opts, {
filename: file
})).bind(this));
};
/**
* Some adapters that compile for client also need helpers, this method
returns a string of minfied JavaScript with all of them
* @return {Promise} A promise for the client-side helpers.
*/
Adapter.prototype.clientHelpers = void 0;
return Adapter;
})();
requireEngine = function(engineName, customPath) {
var engine, err;
if (customPath != null) {
engine = require(resolve.sync(path.basename(customPath), {
basedir: customPath,
preserveSymlinks: false
}));
engine.__accord_path = customPath;
} else {
try {
engine = require(engineName);
engine.__accord_path = resolvePath(engineName);
} catch (error) {
err = error;
throw new Error("'" + engineName + "' not found. make sure it has been installed!");
}
}
try {
if (!engine.version) {
engine.version = require(engine.__accord_path + '/package.json').version;
}
} catch (error) {
err = error;
}
return engine;
};
/**
* Get the path to the root folder of a node module, given its name.
* @param {String} name The name of the node module you want the path to.
* @return {String} The root folder of node module `name`.
* @private
*/
resolvePath = function(name) {
var filepath;
filepath = require.resolve(name);
while (true) {
if (filepath === '/') {
throw new Error("cannot resolve root of node module " + name);
}
filepath = path.dirname(filepath);
if (fs.existsSync(path.join(filepath, 'package.json'))) {
return filepath;
}
}
};
module.exports = Adapter;
}).call(this);

View File

@@ -0,0 +1,55 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, LiveScript, W,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
LiveScript = (function(superClass) {
var compile;
extend(LiveScript, superClass);
function LiveScript() {
return LiveScript.__super__.constructor.apply(this, arguments);
}
LiveScript.prototype.name = 'LiveScript';
LiveScript.prototype.extensions = ['ls'];
LiveScript.prototype.output = 'js';
LiveScript.prototype.isolated = true;
LiveScript.prototype._render = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return LiveScript;
})(Adapter);
module.exports = LiveScript;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./1.x');
}).call(this);

View File

@@ -0,0 +1,74 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Babel, W, path, sourcemaps,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
path = require('path');
W = require('when');
sourcemaps = require('../../sourcemaps');
Babel = (function(superClass) {
var compile;
extend(Babel, superClass);
function Babel() {
return Babel.__super__.constructor.apply(this, arguments);
}
Babel.prototype.name = 'babel';
Babel.prototype.extensions = ['jsx', 'js'];
Babel.prototype.output = 'js';
Babel.prototype.isolated = true;
Babel.prototype._render = function(str, options) {
var filename;
filename = options.filename;
if (options.sourcemap === true) {
options.sourceMap = true;
}
options.sourceMapName = filename;
delete options.sourcemap;
return compile((function(_this) {
return function() {
return _this.engine.transform(str, options);
};
})(this));
};
compile = function(fn) {
var data, err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
data = {
result: res.code
};
if (res.map) {
return sourcemaps.inline_sources(res.map).then(function(map) {
data.sourcemap = map;
return data;
});
} else {
return W.resolve(data);
}
};
return Babel;
})(Adapter);
module.exports = Babel;
}).call(this);

View File

@@ -0,0 +1,86 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Babel, W, path, pick, sourcemaps,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
path = require('path');
W = require('when');
pick = require('lodash.pick');
Adapter = require('../../adapter_base');
sourcemaps = require('../../sourcemaps');
Babel = (function(superClass) {
var compile;
extend(Babel, superClass);
function Babel() {
return Babel.__super__.constructor.apply(this, arguments);
}
Babel.prototype.name = 'babel';
Babel.prototype.extensions = ['js', 'jsx'];
Babel.prototype.output = 'js';
Babel.prototype.isolated = true;
Babel.prototype.supportedEngines = ['babel-core'];
Babel.prototype._render = function(str, options) {
var allowed_keys, filename, sanitized_options;
filename = options.filename;
if (options.sourcemap === true) {
options.sourceMaps = true;
}
options.sourceFileName = filename;
delete options.sourcemap;
allowed_keys = ['filename', 'filenameRelative', 'presets', 'plugins', 'highlightCode', 'only', 'ignore', 'auxiliaryCommentBefore', 'auxiliaryCommentAfter', 'sourceMaps', 'inputSourceMap', 'sourceMapTarget', 'sourceRoot', 'moduleRoot', 'moduleIds', 'moduleId', 'getModuleId', 'resolveModuleSource', 'code', 'babelrc', 'ast', 'compact', 'comments', 'shouldPrintComment', 'env', 'retainLines', 'extends'];
sanitized_options = pick(options, allowed_keys);
return compile((function(_this) {
return function() {
return _this.engine.transform(str, sanitized_options);
};
})(this));
};
compile = function(fn) {
var data, dirname, err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
data = {
result: res.code
};
if (res.map) {
if (res.map.sources) {
dirname = path.dirname(res.options.filename);
res.map.sources = res.map.sources.map(function(source) {
return path.join(dirname, source);
});
}
return sourcemaps.inline_sources(res.map).then(function(map) {
data.sourcemap = map;
return data;
});
} else {
return W.resolve(data);
}
};
return Babel;
})(Adapter);
module.exports = Babel;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./6.x');
}).call(this);

View File

@@ -0,0 +1,68 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Buble, W, path, sourcemaps,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
path = require('path');
W = require('when');
sourcemaps = require('../../sourcemaps');
Buble = (function(superClass) {
var compile;
extend(Buble, superClass);
function Buble() {
return Buble.__super__.constructor.apply(this, arguments);
}
Buble.prototype.name = 'buble';
Buble.prototype.extensions = ['js'];
Buble.prototype.output = 'js';
Buble.prototype.isolated = true;
Buble.prototype._render = function(str, options) {
options.source = options.filename;
return compile((function(_this) {
return function() {
return _this.engine.transform(str, options);
};
})(this));
};
compile = function(fn) {
var data, err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
data = {
result: res.code
};
if (res.map) {
return sourcemaps.inline_sources(res.map).then(function(map) {
data.sourcemap = map;
return data;
});
} else {
return W.resolve(data);
}
};
return Buble;
})(Adapter);
module.exports = Buble;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./0.8.x - 0.15.x');
}).call(this);

View File

@@ -0,0 +1,63 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, CJSX, W, path, sourcemaps,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
sourcemaps = require('../../sourcemaps');
path = require('path');
W = require('when');
CJSX = (function(superClass) {
var compile;
extend(CJSX, superClass);
function CJSX() {
return CJSX.__super__.constructor.apply(this, arguments);
}
CJSX.prototype.name = 'cjsx';
CJSX.prototype.extensions = ['cjsx'];
CJSX.prototype.output = 'coffee';
CJSX.prototype.supportedEngines = ['coffee-react-transform'];
CJSX.prototype.isolated = true;
CJSX.prototype._render = function(str, options) {
var filename;
filename = options.filename;
return compile((function(_this) {
return function() {
return _this.engine(str);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return CJSX;
})(Adapter);
module.exports = CJSX;
}).call(this);

View File

@@ -0,0 +1,63 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, CJSX, W, path, sourcemaps,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
sourcemaps = require('../../sourcemaps');
path = require('path');
W = require('when');
CJSX = (function(superClass) {
var compile;
extend(CJSX, superClass);
function CJSX() {
return CJSX.__super__.constructor.apply(this, arguments);
}
CJSX.prototype.name = 'cjsx';
CJSX.prototype.extensions = ['cjsx'];
CJSX.prototype.output = 'coffee';
CJSX.prototype.supportedEngines = ['coffee-react-transform'];
CJSX.prototype.isolated = true;
CJSX.prototype._render = function(str, options) {
var filename;
filename = options.filename;
return compile((function(_this) {
return function() {
return _this.engine(str);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return CJSX;
})(Adapter);
module.exports = CJSX;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./4.x - 5.x');
}).call(this);

View File

@@ -0,0 +1,55 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Coco, W,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
Coco = (function(superClass) {
var compile;
extend(Coco, superClass);
function Coco() {
return Coco.__super__.constructor.apply(this, arguments);
}
Coco.prototype.name = 'coco';
Coco.prototype.extensions = ['co'];
Coco.prototype.output = 'js';
Coco.prototype.isolated = true;
Coco.prototype._render = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return Coco;
})(Adapter);
module.exports = Coco;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./0.9.x');
}).call(this);

View File

@@ -0,0 +1,80 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, CoffeeScript, W, path, sourcemaps,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
sourcemaps = require('../../sourcemaps');
path = require('path');
W = require('when');
CoffeeScript = (function(superClass) {
var compile;
extend(CoffeeScript, superClass);
function CoffeeScript() {
return CoffeeScript.__super__.constructor.apply(this, arguments);
}
CoffeeScript.prototype.name = 'coffee-script';
CoffeeScript.prototype.extensions = ['coffee'];
CoffeeScript.prototype.output = 'js';
CoffeeScript.prototype.isolated = true;
CoffeeScript.prototype._render = function(str, options) {
var filename;
filename = options.filename;
if (options.sourcemap === true) {
options.sourceMap = true;
}
options.sourceFiles = [filename];
if (options.filename) {
options.generatedFile = path.basename(filename).replace('.coffee', '.js');
}
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options);
};
})(this));
};
compile = function(fn) {
var data, err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
if (res.sourceMap) {
data = {
result: res.js,
v2sourcemap: res.sourceMap,
sourcemap: JSON.parse(res.v3SourceMap)
};
return sourcemaps.inline_sources(data.sourcemap).then(function(map) {
data.sourcemap = map;
return data;
});
} else {
return W.resolve({
result: res
});
}
};
return CoffeeScript;
})(Adapter);
module.exports = CoffeeScript;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./1.x');
}).call(this);

View File

@@ -0,0 +1,58 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, CSSO, W,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
CSSO = (function(superClass) {
var compile;
extend(CSSO, superClass);
function CSSO() {
return CSSO.__super__.constructor.apply(this, arguments);
}
CSSO.prototype.name = 'csso';
CSSO.prototype.extensions = ['css'];
CSSO.prototype.output = 'css';
CSSO.prototype.isolated = true;
CSSO.prototype._render = function(str, options) {
if (options.noRestructure == null) {
options.noRestructure = false;
}
return compile((function(_this) {
return function() {
return _this.engine.justDoIt(str, options.noRestructure);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return CSSO;
})(Adapter);
module.exports = CSSO;
}).call(this);

View File

@@ -0,0 +1,61 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, CSSO, W,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
CSSO = (function(superClass) {
var compile;
extend(CSSO, superClass);
function CSSO() {
return CSSO.__super__.constructor.apply(this, arguments);
}
CSSO.prototype.name = 'csso';
CSSO.prototype.extensions = ['css'];
CSSO.prototype.output = 'css';
CSSO.prototype.isolated = true;
CSSO.prototype._render = function(str, options) {
if (options.restructuring == null) {
options.restructuring = true;
}
if (options.debug == null) {
options.debug = false;
}
return compile((function(_this) {
return function() {
return _this.engine.minify(str, options).css;
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return CSSO;
})(Adapter);
module.exports = CSSO;
}).call(this);

View File

@@ -0,0 +1,61 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, CSSO, W,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
CSSO = (function(superClass) {
var compile;
extend(CSSO, superClass);
function CSSO() {
return CSSO.__super__.constructor.apply(this, arguments);
}
CSSO.prototype.name = 'csso';
CSSO.prototype.extensions = ['css'];
CSSO.prototype.output = 'css';
CSSO.prototype.isolated = true;
CSSO.prototype._render = function(str, options) {
if (options.restructuring == null) {
options.restructuring = true;
}
if (options.debug == null) {
options.debug = false;
}
return compile((function(_this) {
return function() {
return _this.engine.minify(str, options);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return CSSO;
})(Adapter);
module.exports = CSSO;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./2.x - 3.x');
}).call(this);

View File

@@ -0,0 +1,38 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, DogeScript, W,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
DogeScript = (function(superClass) {
extend(DogeScript, superClass);
function DogeScript() {
return DogeScript.__super__.constructor.apply(this, arguments);
}
DogeScript.prototype.name = 'dogescript';
DogeScript.prototype.extensions = ['djs'];
DogeScript.prototype.output = 'js';
DogeScript.prototype.isolated = true;
DogeScript.prototype._render = function(str, options) {
return W.resolve({
result: this.engine(str, options.beauty, options.trueDoge)
});
};
return DogeScript;
})(Adapter);
module.exports = DogeScript;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./2.x');
}).call(this);

View File

@@ -0,0 +1,80 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Dot, W, fs, path,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
path = require('path');
fs = require('fs');
W = require('when');
Dot = (function(superClass) {
var compile;
extend(Dot, superClass);
function Dot() {
return Dot.__super__.constructor.apply(this, arguments);
}
Dot.prototype.name = 'dot';
Dot.prototype.extensions = ['dot'];
Dot.prototype.output = 'html';
Dot.prototype._render = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str)(options);
};
})(this));
};
Dot.prototype._compile = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options);
};
})(this));
};
Dot.prototype._compileClient = function(str, options) {
options.client = true;
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options).toString();
};
})(this));
};
Dot.prototype.clientHelpers = function(str, options) {
var runtime_path;
runtime_path = path.join(this.engine.__accord_path, 'doT.min.js');
return fs.readFileSync(runtime_path, 'utf8');
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return Dot;
})(Adapter);
module.exports = Dot;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./1.x');
}).call(this);

View File

@@ -0,0 +1,76 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Eco, W, fs, path,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
path = require('path');
fs = require('fs');
W = require('when');
Eco = (function(superClass) {
var compile;
extend(Eco, superClass);
function Eco() {
return Eco.__super__.constructor.apply(this, arguments);
}
Eco.prototype.name = 'eco';
Eco.prototype.extensions = ['eco'];
Eco.prototype.output = 'html';
Eco.prototype._render = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.render(str, options);
};
})(this));
};
Eco.prototype._compile = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options);
};
})(this)).then(function(res) {
res.result = eval(res.result);
return res;
});
};
Eco.prototype._compileClient = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options).toString().trim() + '\n';
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return Eco;
})(Adapter);
module.exports = Eco;
}).call(this);

View File

@@ -0,0 +1,73 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Eco, W, fs, path,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
path = require('path');
fs = require('fs');
W = require('when');
Eco = (function(superClass) {
var compile;
extend(Eco, superClass);
function Eco() {
return Eco.__super__.constructor.apply(this, arguments);
}
Eco.prototype.name = 'eco';
Eco.prototype.extensions = ['eco'];
Eco.prototype.output = 'html';
Eco.prototype._render = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.render(str, options);
};
})(this));
};
Eco.prototype._compile = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options);
};
})(this));
};
Eco.prototype._compileClient = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options).toString().trim() + '\n';
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return Eco;
})(Adapter);
module.exports = Eco;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./1.x');
}).call(this);

View File

@@ -0,0 +1,80 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, EJS, W, fs, path,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
path = require('path');
fs = require('fs');
W = require('when');
EJS = (function(superClass) {
var compile;
extend(EJS, superClass);
function EJS() {
return EJS.__super__.constructor.apply(this, arguments);
}
EJS.prototype.name = 'ejs';
EJS.prototype.extensions = ['ejs'];
EJS.prototype.output = 'html';
EJS.prototype._render = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.render(str, options);
};
})(this));
};
EJS.prototype._compile = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options);
};
})(this));
};
EJS.prototype._compileClient = function(str, options) {
options.client = true;
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options).toString();
};
})(this));
};
EJS.prototype.clientHelpers = function(str, options) {
var runtime_path;
runtime_path = path.join(this.engine.__accord_path, 'ejs.min.js');
return fs.readFileSync(runtime_path, 'utf8');
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return EJS;
})(Adapter);
module.exports = EJS;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./2.x');
}).call(this);

View File

@@ -0,0 +1,62 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, EscapeHTML, W, defaults,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
defaults = require('lodash.defaults');
EscapeHTML = (function(superClass) {
var compile;
extend(EscapeHTML, superClass);
function EscapeHTML() {
return EscapeHTML.__super__.constructor.apply(this, arguments);
}
EscapeHTML.prototype.name = 'escape-html';
EscapeHTML.prototype.extensions = ['html'];
EscapeHTML.prototype.output = 'html';
EscapeHTML.prototype.supportedEngines = ['he'];
EscapeHTML.prototype.isolated = true;
EscapeHTML.prototype._render = function(str, options) {
options = defaults(options, {
allowUnsafeSymbols: true
});
return compile((function(_this) {
return function() {
return _this.engine.encode(str, options);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return EscapeHTML;
})(Adapter);
module.exports = EscapeHTML;
}).call(this);

View File

@@ -0,0 +1,62 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, EscapeHTML, W, defaults,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
defaults = require('lodash.defaults');
EscapeHTML = (function(superClass) {
var compile;
extend(EscapeHTML, superClass);
function EscapeHTML() {
return EscapeHTML.__super__.constructor.apply(this, arguments);
}
EscapeHTML.prototype.name = 'escape-html';
EscapeHTML.prototype.extensions = ['html'];
EscapeHTML.prototype.output = 'html';
EscapeHTML.prototype.supportedEngines = ['he'];
EscapeHTML.prototype.isolated = true;
EscapeHTML.prototype._render = function(str, options) {
options = defaults(options, {
allowUnsafeSymbols: true
});
return compile((function(_this) {
return function() {
return _this.engine.encode(str, options);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return EscapeHTML;
})(Adapter);
module.exports = EscapeHTML;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./1.x');
}).call(this);

View File

@@ -0,0 +1,69 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, HAML, UglifyJS, W, fs, path,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
path = require('path');
fs = require('fs');
W = require('when');
UglifyJS = require('uglify-js');
HAML = (function(superClass) {
var compile;
extend(HAML, superClass);
function HAML() {
return HAML.__super__.constructor.apply(this, arguments);
}
HAML.prototype.name = 'haml';
HAML.prototype.extensions = ['haml'];
HAML.prototype.output = 'html';
HAML.prototype.supportedEngines = ['hamljs'];
HAML.prototype._render = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str)(options);
};
})(this));
};
HAML.prototype._compile = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return HAML;
})(Adapter);
module.exports = HAML;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./0.6.x');
}).call(this);

View File

@@ -0,0 +1,106 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Handlebars, W, clone, fs, merge, path,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
clone = require('lodash.clone');
merge = require('lodash.merge');
path = require('path');
fs = require('fs');
W = require('when');
Handlebars = (function(superClass) {
var compile, register_helpers;
extend(Handlebars, superClass);
function Handlebars() {
return Handlebars.__super__.constructor.apply(this, arguments);
}
Handlebars.prototype.name = 'handlebars';
Handlebars.prototype.extensions = ['hbs', 'handlebars'];
Handlebars.prototype.output = 'html';
Handlebars.prototype._render = function(str, options) {
var compiler;
compiler = clone(this.engine);
register_helpers(compiler, options);
return compile((function(_this) {
return function() {
return compiler.compile(str)(options);
};
})(this));
};
Handlebars.prototype._compile = function(str, options) {
var compiler;
compiler = clone(this.engine);
register_helpers(compiler, options);
return compile((function(_this) {
return function() {
return compiler.compile(str);
};
})(this));
};
Handlebars.prototype._compileClient = function(str, options) {
var compiler;
compiler = clone(this.engine);
register_helpers(compiler, options);
return compile((function(_this) {
return function() {
return "Handlebars.template(" + (compiler.precompile(str)) + ");";
};
})(this));
};
Handlebars.prototype.clientHelpers = function() {
var runtime_path;
runtime_path = path.join(this.engine.__accord_path, 'dist/handlebars.runtime.min.js');
return fs.readFileSync(runtime_path, 'utf8');
};
/**
* @private
*/
register_helpers = function(compiler, opts) {
if (opts.helpers) {
compiler.helpers = merge(compiler.helpers, opts.helpers);
}
if (opts.partials) {
return compiler.partials = merge(compiler.partials, opts.partials);
}
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return Handlebars;
})(Adapter);
module.exports = Handlebars;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./3.x - 4.x');
}).call(this);

View File

@@ -0,0 +1,86 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Jade, UglifyJS, W, fs, path,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
path = require('path');
fs = require('fs');
W = require('when');
UglifyJS = require('uglify-js');
Jade = (function(superClass) {
var compile;
extend(Jade, superClass);
function Jade() {
return Jade.__super__.constructor.apply(this, arguments);
}
Jade.prototype.name = 'jade';
Jade.prototype.extensions = ['jade'];
Jade.prototype.output = 'html';
Jade.prototype.supportedEngines = ['jade'];
Jade.prototype._render = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.render(str, options);
};
})(this));
};
Jade.prototype._compile = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options);
};
})(this));
};
Jade.prototype._compileClient = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compileClient(str, options);
};
})(this));
};
Jade.prototype.clientHelpers = function() {
var runtime, runtime_path;
runtime_path = path.join(this.engine.__accord_path, 'runtime.js');
runtime = fs.readFileSync(runtime_path, 'utf8');
return UglifyJS.minify(runtime, {
fromString: true
}).code;
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return Jade;
})(Adapter);
module.exports = Jade;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./1.x');
}).call(this);

View File

@@ -0,0 +1,78 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, JSX, W, path, sourcemaps,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
sourcemaps = require('../../sourcemaps');
path = require('path');
W = require('when');
JSX = (function(superClass) {
var compile;
extend(JSX, superClass);
function JSX() {
return JSX.__super__.constructor.apply(this, arguments);
}
JSX.prototype.name = 'jsx';
JSX.prototype.extensions = ['jsx'];
JSX.prototype.output = 'js';
JSX.prototype.supportedEngines = ['react-tools'];
JSX.prototype.isolated = true;
JSX.prototype._render = function(str, options) {
if (options.sourcemap === true) {
options.sourceMap = true;
options.sourceFilename = options.filename;
}
return compile(options, (function(_this) {
return function() {
return _this.engine.transformWithDetails(str, options);
};
})(this));
};
compile = function(opts, fn) {
var data, err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
if (res.sourceMap) {
data = {
result: res.code,
sourcemap: res.sourceMap
};
data.sourcemap.sources.pop();
data.sourcemap.sources.push(opts.filename);
return sourcemaps.inline_sources(data.sourcemap).then(function(map) {
data.sourcemap = map;
return data;
});
} else {
return W.resolve({
result: res.code
});
}
};
return JSX;
})(Adapter);
module.exports = JSX;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./0.13.x');
}).call(this);

View File

@@ -0,0 +1,67 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Less, W, sourcemaps,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
sourcemaps = require('../../sourcemaps');
W = require('when');
Less = (function(superClass) {
extend(Less, superClass);
function Less() {
return Less.__super__.constructor.apply(this, arguments);
}
Less.prototype.name = 'less';
Less.prototype.extensions = ['less'];
Less.prototype.output = 'css';
/**
* LESS has import rules for other LESS stylesheets
*/
Less.prototype.isolated = false;
Less.prototype._render = function(str, options) {
var deferred;
deferred = W.defer();
if (options.sourcemap === true) {
options.sourceMap = true;
}
this.engine.render(str, options, function(err, res) {
var obj;
if (err) {
return deferred.reject(err);
}
obj = {
result: res.css,
imports: res.imports
};
if (options.sourceMap && res.map) {
obj.sourcemap = JSON.parse(res.map);
return sourcemaps.inline_sources(obj.sourcemap).then(function(map) {
obj.sourcemap = map;
return deferred.resolve(obj);
});
} else {
return deferred.resolve(obj);
}
});
return deferred.promise;
};
return Less;
})(Adapter);
module.exports = Less;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./2.x - 3.x');
}).call(this);

View File

@@ -0,0 +1,57 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Marc, W,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
Marc = (function(superClass) {
extend(Marc, superClass);
function Marc() {
return Marc.__super__.constructor.apply(this, arguments);
}
Marc.prototype.name = 'marc';
Marc.prototype.extensions = ['md'];
Marc.prototype.output = 'html';
Marc.prototype._render = function(str, options) {
var base, k, ref, ref1, ref2, v;
base = this.engine();
ref = options['data'];
for (k in ref) {
v = ref[k];
base.set(k, v);
}
delete options['data'];
ref1 = options['partial'];
for (k in ref1) {
v = ref1[k];
base.partial(k, v);
}
delete options['partial'];
ref2 = options['filter'];
for (k in ref2) {
v = ref2[k];
base.filter(k, v);
}
delete options['filter'];
base.config(options);
return W.resolve({
result: base(str, true)
});
};
return Marc;
})(Adapter);
module.exports = Marc;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./0.1.x');
}).call(this);

View File

@@ -0,0 +1,42 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Markdown, nodefn,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
nodefn = require('when/node/function');
Markdown = (function(superClass) {
extend(Markdown, superClass);
function Markdown() {
return Markdown.__super__.constructor.apply(this, arguments);
}
Markdown.prototype.name = 'markdown';
Markdown.prototype.extensions = ['md', 'mdown', 'markdown'];
Markdown.prototype.output = 'html';
Markdown.prototype.supportedEngines = ['marked'];
Markdown.prototype.isolated = true;
Markdown.prototype._render = function(str, options) {
return nodefn.call(this.engine.bind(this.engine), str, options).then(function(res) {
return {
result: res
};
});
};
return Markdown;
})(Adapter);
module.exports = Markdown;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./0.3.x');
}).call(this);

View File

@@ -0,0 +1,68 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, MinifyCSS, W,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
MinifyCSS = (function(superClass) {
var compile;
extend(MinifyCSS, superClass);
function MinifyCSS() {
return MinifyCSS.__super__.constructor.apply(this, arguments);
}
MinifyCSS.prototype.name = 'minify-css';
MinifyCSS.prototype.extensions = ['css'];
MinifyCSS.prototype.output = 'css';
MinifyCSS.prototype.supportedEngines = ['clean-css'];
/**
* It is sometimes isolated, but not always because you can get it to process
`import` rules with `processImport`
*/
MinifyCSS.prototype.isolated = false;
MinifyCSS.prototype._render = function(str, options) {
return compile((function(_this) {
return function() {
return (new _this.engine(options)).minify(str);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
if (res.errors.length > 0) {
W.reject(res);
}
return W.resolve({
result: res.styles,
warnings: res.warnings,
stats: res.stats
});
};
return MinifyCSS;
})(Adapter);
module.exports = MinifyCSS;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./3.x - 4.x');
}).call(this);

View File

@@ -0,0 +1,71 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, MinifyHTML, W, defaults,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
defaults = require('lodash.defaults');
MinifyHTML = (function(superClass) {
var compile;
extend(MinifyHTML, superClass);
function MinifyHTML() {
return MinifyHTML.__super__.constructor.apply(this, arguments);
}
MinifyHTML.prototype.name = 'minify-html';
MinifyHTML.prototype.extensions = ['html'];
MinifyHTML.prototype.output = 'html';
MinifyHTML.prototype.supportedEngines = ['html-minifier'];
/**
* I think that you could cause this to not be isolated by using the minifyCSS
option and then making that import stylesheets, but I'm not even sure if
MinifyHTML would support that...
*/
MinifyHTML.prototype.isolated = true;
MinifyHTML.prototype._render = function(str, options) {
options = defaults(options, {
removeComments: true,
collapseWhitespace: true,
removeEmptyAttributes: true
});
return compile((function(_this) {
return function() {
return _this.engine.minify(str, options);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return MinifyHTML;
})(Adapter);
module.exports = MinifyHTML;
}).call(this);

View File

@@ -0,0 +1,71 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, MinifyHTML, W, defaults,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
defaults = require('lodash.defaults');
MinifyHTML = (function(superClass) {
var compile;
extend(MinifyHTML, superClass);
function MinifyHTML() {
return MinifyHTML.__super__.constructor.apply(this, arguments);
}
MinifyHTML.prototype.name = 'minify-html';
MinifyHTML.prototype.extensions = ['html'];
MinifyHTML.prototype.output = 'html';
MinifyHTML.prototype.supportedEngines = ['html-minifier'];
/**
* I think that you could cause this to not be isolated by using the minifyCSS
option and then making that import stylesheets, but I'm not even sure if
MinifyHTML would support that...
*/
MinifyHTML.prototype.isolated = true;
MinifyHTML.prototype._render = function(str, options) {
options = defaults(options, {
removeComments: true,
collapseWhitespace: true,
removeEmptyAttributes: true
});
return compile((function(_this) {
return function() {
return _this.engine.minify(str, options);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return MinifyHTML;
})(Adapter);
module.exports = MinifyHTML;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./2.x - 3.x');
}).call(this);

View File

@@ -0,0 +1,83 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, MinifyJS, W, convert, path, sourcemaps,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
sourcemaps = require('../../sourcemaps');
W = require('when');
path = require('path');
convert = require('convert-source-map');
MinifyJS = (function(superClass) {
var compile;
extend(MinifyJS, superClass);
function MinifyJS() {
return MinifyJS.__super__.constructor.apply(this, arguments);
}
MinifyJS.prototype.name = 'minify-js';
MinifyJS.prototype.extensions = ['js'];
MinifyJS.prototype.output = 'js';
MinifyJS.prototype.supportedEngines = ['uglify-js'];
MinifyJS.prototype.isolated = true;
MinifyJS.prototype._render = function(str, options) {
if (options.sourcemap === true) {
options.sourceMap = true;
options.outSourceMap = path.basename(options.filename);
}
return compile((function(_this) {
return function() {
var obj, res;
res = _this.engine.minify(str, Object.assign(options, {
fromString: true
}));
obj = {
result: res.code
};
if (options.sourceMap) {
obj.sourcemap = JSON.parse(res.map);
obj.sourcemap.sources.pop();
obj.sourcemap.sources.push(options.filename);
obj.result = convert.removeMapFileComments(obj.result).trim();
return sourcemaps.inline_sources(obj.sourcemap).then(function(map) {
obj.sourcemap = map;
return obj;
});
} else {
return obj;
}
};
})(this));
};
compile = function(fn, map) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve(res);
};
return MinifyJS;
})(Adapter);
module.exports = MinifyJS;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./2.x');
}).call(this);

View File

@@ -0,0 +1,85 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Mustache, W, fs, path, util,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
util = require('util');
fs = require('fs');
path = require('path');
Mustache = (function(superClass) {
var compile;
extend(Mustache, superClass);
function Mustache() {
return Mustache.__super__.constructor.apply(this, arguments);
}
Mustache.prototype.name = 'mustache';
Mustache.prototype.extensions = ['mustache', 'hogan'];
Mustache.prototype.output = 'html';
Mustache.prototype.supportedEngines = ['hogan.js'];
Mustache.prototype._render = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options).render(options, options.partials);
};
})(this));
};
Mustache.prototype._compile = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options);
};
})(this));
};
Mustache.prototype._compileClient = function(str, options) {
options.asString = true;
return this._compile(str, options).then(function(o) {
return {
result: "new Hogan.Template(" + (o.result.toString()) + ");"
};
});
};
Mustache.prototype.clientHelpers = function() {
var runtime_path, version;
version = require(path.join(this.engine.__accord_path, 'package')).version;
runtime_path = path.join(this.engine.__accord_path, "web/builds/" + version + "/hogan-" + version + ".min.js");
return fs.readFileSync(runtime_path, 'utf8');
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return Mustache;
})(Adapter);
module.exports = Mustache;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./3.x');
}).call(this);

View File

@@ -0,0 +1,66 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Myth, W, convert,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
convert = require('convert-source-map');
W = require('when');
Myth = (function(superClass) {
var compile;
extend(Myth, superClass);
function Myth() {
return Myth.__super__.constructor.apply(this, arguments);
}
Myth.prototype.name = 'myth';
Myth.prototype.extensions = ['myth', 'mcss'];
Myth.prototype.output = 'css';
Myth.prototype._render = function(str, options) {
options.source = options.filename;
delete options.filename;
return compile(options.sourcemap, ((function(_this) {
return function() {
return _this.engine(str, options);
};
})(this)));
};
compile = function(sourcemap, fn) {
var data, err, map, res, src;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
data = {
result: res
};
if (sourcemap) {
map = convert.fromSource(res).sourcemap;
src = convert.removeComments(res);
data = {
result: src,
sourcemap: map
};
}
return W.resolve(data);
};
return Myth;
})(Adapter);
module.exports = Myth;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./1.x');
}).call(this);

View File

@@ -0,0 +1,64 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, PostCSS, W, convert, path, sourcemaps,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
sourcemaps = require('../../sourcemaps');
W = require('when');
path = require('path');
convert = require('convert-source-map');
PostCSS = (function(superClass) {
extend(PostCSS, superClass);
function PostCSS() {
return PostCSS.__super__.constructor.apply(this, arguments);
}
PostCSS.prototype.name = 'postcss';
PostCSS.prototype.extensions = ['css', 'pcss', 'sss'];
PostCSS.prototype.output = 'css';
PostCSS.prototype._render = function(str, options) {
var processor, ref, use;
use = (ref = options.use) != null ? ref : [];
processor = this.engine(use);
if (options.map === true) {
options.map = {
inline: false
};
options.from = options.filename;
}
return W(processor.process(str, options)).then(function(res) {
var obj;
obj = {
result: res.css
};
if (options.map) {
obj.sourcemap = JSON.parse(res.map);
obj.result = convert.removeMapFileComments(obj.result).trim();
return sourcemaps.inline_sources(obj.sourcemap).then(function(map) {
obj.sourcemap = map;
return obj;
});
} else {
return obj;
}
});
};
return PostCSS;
})(Adapter);
module.exports = PostCSS;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./4.x - 5.x');
}).call(this);

View File

@@ -0,0 +1,77 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Pug, UglifyJS, W, fs, path,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
path = require('path');
fs = require('fs');
W = require('when');
UglifyJS = require('uglify-js');
Pug = (function(superClass) {
var compile;
extend(Pug, superClass);
function Pug() {
return Pug.__super__.constructor.apply(this, arguments);
}
Pug.prototype.name = 'pug';
Pug.prototype.extensions = ['pug'];
Pug.prototype.output = 'html';
Pug.prototype.supportedEngines = ['pug'];
Pug.prototype._render = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.render(str, options);
};
})(this));
};
Pug.prototype._compile = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options);
};
})(this));
};
Pug.prototype._compileClient = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compileClient(str, options);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return Pug;
})(Adapter);
module.exports = Pug;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./2.0.0-rc - 2.x');
}).call(this);

View File

@@ -0,0 +1,75 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, SCSS, W, path,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
path = require('path');
SCSS = (function(superClass) {
extend(SCSS, superClass);
function SCSS() {
return SCSS.__super__.constructor.apply(this, arguments);
}
SCSS.prototype.name = 'scss';
SCSS.prototype.extensions = ['scss', 'sass'];
SCSS.prototype.output = 'css';
SCSS.prototype.supportedEngines = ['node-sass'];
SCSS.prototype._render = function(str, options) {
var deferred;
deferred = W.defer();
if (options.sourcemap) {
if (typeof options.sourcemap === 'string') {
options.sourceMap = options.sourcemap;
} else {
options.sourceMap = true;
}
options.outFile = path.basename(options.filename).replace('.scss', '.css');
options.omitSourceMapUrl = true;
options.sourceMapContents = true;
}
options.file = options.filename;
options.data = str;
options.error = function(err) {
return deferred.reject(err);
};
options.success = function(res) {
var data;
data = {
result: String(res.css),
imports: res.stats.includedFiles,
meta: {
entry: res.stats.entry,
start: res.stats.start,
end: res.stats.end,
duration: res.stats.duration
}
};
if (res.map && Object.keys(JSON.parse(res.map)).length) {
data.sourcemap = JSON.parse(res.map);
data.sourcemap.sources.pop();
data.sourcemap.sources.push(options.file);
}
return deferred.resolve(data);
};
this.engine.render(options);
return deferred.promise;
};
return SCSS;
})(Adapter);
module.exports = SCSS;
}).call(this);

View File

@@ -0,0 +1,78 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, SCSS, W, path,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
path = require('path');
SCSS = (function(superClass) {
extend(SCSS, superClass);
function SCSS() {
return SCSS.__super__.constructor.apply(this, arguments);
}
SCSS.prototype.name = 'scss';
SCSS.prototype.extensions = ['scss', 'sass'];
SCSS.prototype.output = 'css';
SCSS.prototype.supportedEngines = ['node-sass'];
SCSS.prototype._render = function(str, options) {
var deferred;
deferred = W.defer();
if (options.sourcemap) {
if (typeof options.sourcemap === 'string') {
options.sourceMap = options.sourcemap;
} else {
options.sourceMap = true;
}
options.outFile = options.filename.replace('.scss', '.css');
options.omitSourceMapUrl = true;
options.sourceMapContents = true;
}
options.file = options.filename;
options.data = str;
this.engine.render(options, function(err, res) {
var basePath, data;
if (err) {
return deferred.reject(err);
}
data = {
result: String(res.css),
imports: res.stats.includedFiles,
meta: {
entry: res.stats.entry,
start: res.stats.start,
end: res.stats.end,
duration: res.stats.duration
}
};
if (res.map) {
data.sourcemap = JSON.parse(res.map.toString('utf8'));
basePath = path.dirname(options.filename);
if (typeof options.sourceMap !== 'string') {
data.sourcemap.sources = data.sourcemap.sources.map(function(relativePath) {
return path.join(basePath, relativePath);
});
}
}
return deferred.resolve(data);
});
return deferred.promise;
};
return SCSS;
})(Adapter);
module.exports = SCSS;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./3.x - 4.x');
}).call(this);

View File

@@ -0,0 +1,127 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Stylus, flatten, nodefn, sourcemaps,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
sourcemaps = require('../../sourcemaps');
nodefn = require('when/node/function');
flatten = require('lodash.flatten');
Stylus = (function(superClass) {
extend(Stylus, superClass);
function Stylus() {
return Stylus.__super__.constructor.apply(this, arguments);
}
Stylus.prototype.name = 'stylus';
Stylus.prototype.extensions = ['styl'];
Stylus.prototype.output = 'css';
Stylus.prototype._render = function(str, options) {
var base, defines, i, imports, includes, j, k, l, len, len1, len2, m, obj, plugins, rawDefines, sets, v;
sets = {};
defines = {};
rawDefines = {};
includes = [];
imports = [];
plugins = [];
if (options.sourcemap === true) {
options.sourcemap = {
comment: false
};
}
for (k in options) {
v = options[k];
switch (k) {
case 'define':
Object.assign(defines, v);
break;
case 'rawDefine':
Object.assign(rawDefines, v);
break;
case 'include':
includes.push(v);
break;
case 'import':
imports.push(v);
break;
case 'use':
plugins.push(v);
break;
case 'url':
if (typeof v === 'string') {
obj = {};
obj[v] = this.engine.url();
Object.assign(defines, obj);
} else {
obj = {};
obj[v.name] = this.engine.url({
limit: v.limit != null ? v.limit : 30000,
paths: v.paths || []
});
Object.assign(defines, obj);
}
break;
default:
sets[k] = v;
}
}
includes = flatten(includes);
imports = flatten(imports);
plugins = flatten(plugins);
base = this.engine(str);
for (k in sets) {
v = sets[k];
base.set(k, v);
}
for (k in defines) {
v = defines[k];
base.define(k, v);
}
for (k in rawDefines) {
v = rawDefines[k];
base.define(k, v, true);
}
for (j = 0, len = includes.length; j < len; j++) {
i = includes[j];
base.include(i);
}
for (l = 0, len1 = imports.length; l < len1; l++) {
i = imports[l];
base["import"](i);
}
for (m = 0, len2 = plugins.length; m < len2; m++) {
i = plugins[m];
base.use(i);
}
return nodefn.call(base.render.bind(base)).then(function(res) {
return obj = {
result: res
};
}).then(function(obj) {
if (base.sourcemap) {
return sourcemaps.inline_sources(base.sourcemap).then(function(map) {
obj.sourcemap = map;
return obj;
});
} else {
return obj;
}
});
};
return Stylus;
})(Adapter);
module.exports = Stylus;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./0.x');
}).call(this);

View File

@@ -0,0 +1,103 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Swig, UglifyJS, W, fs, path,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
path = require('path');
fs = require('fs');
W = require('when');
UglifyJS = require('uglify-js');
Swig = (function(superClass) {
var compile;
extend(Swig, superClass);
function Swig() {
return Swig.__super__.constructor.apply(this, arguments);
}
Swig.prototype.name = 'swig';
Swig.prototype.extensions = ['swig'];
Swig.prototype.output = 'html';
Swig.prototype._render = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.render(str, options);
};
})(this));
};
Swig.prototype._compile = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compile(str, options);
};
})(this));
};
Swig.prototype._compileClient = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.precompile(str, options).tpl.toString();
};
})(this));
};
Swig.prototype.renderFile = function(path, options) {
if (options == null) {
options = {};
}
return compile((function(_this) {
return function() {
return _this.engine.renderFile(path, options.locals);
};
})(this));
};
Swig.prototype.compileFile = function(path, options) {
if (options == null) {
options = {};
}
return compile((function(_this) {
return function() {
return _this.engine.compileFile(path, options);
};
})(this));
};
Swig.prototype.clientHelpers = function() {
var runtime_path;
runtime_path = path.join(this.engine.__accord_path, 'dist/swig.min.js');
return fs.readFileSync(runtime_path, 'utf8');
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return Swig;
})(Adapter);
module.exports = Swig;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./1.x');
}).call(this);

View File

@@ -0,0 +1,79 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, Toffee, W, fs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
fs = require('fs');
Toffee = (function(superClass) {
var compile;
extend(Toffee, superClass);
function Toffee() {
return Toffee.__super__.constructor.apply(this, arguments);
}
Toffee.prototype.name = 'toffee';
Toffee.prototype.extensions = ['toffee'];
Toffee.prototype.output = 'html';
Toffee.prototype.supportedEngines = ['toffee'];
Toffee.prototype._render = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.str_render(str, options, function(err, res) {
if (res.indexOf("<div style=\"font-family:courier new;font-size:12px;color:#900;width:100%;\">") !== -1) {
throw res;
} else {
return res;
}
});
};
})(this));
};
Toffee.prototype._compile = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.compileStr(str).toString();
};
})(this));
};
Toffee.prototype._compileClient = function(str, options) {
return compile((function(_this) {
return function() {
return _this.engine.configurable_compile(str, options);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return Toffee;
})(Adapter);
module.exports = Toffee;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./0.1.x');
}).call(this);

View File

@@ -0,0 +1,63 @@
// Generated by CoffeeScript 1.12.7
(function() {
var Adapter, TypeScript, W,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Adapter = require('../../adapter_base');
W = require('when');
TypeScript = (function(superClass) {
var compile;
extend(TypeScript, superClass);
function TypeScript() {
return TypeScript.__super__.constructor.apply(this, arguments);
}
TypeScript.prototype.name = 'typescript';
TypeScript.prototype.engineName = 'typescript-compiler';
TypeScript.prototype.supportedEngines = ['typescript-compiler'];
TypeScript.prototype.extensions = ['ts'];
TypeScript.prototype.output = 'js';
TypeScript.prototype.isolated = true;
TypeScript.prototype._render = function(str, options) {
var throwOnError;
throwOnError = function(err) {
throw err;
};
return compile((function(_this) {
return function() {
return _this.engine.compileString(str, void 0, options, throwOnError);
};
})(this));
};
compile = function(fn) {
var err, res;
try {
res = fn();
} catch (error) {
err = error;
return W.reject(err);
}
return W.resolve({
result: res
});
};
return TypeScript;
})(Adapter);
module.exports = TypeScript;
}).call(this);

View File

@@ -0,0 +1,5 @@
// Generated by CoffeeScript 1.12.7
(function() {
module.exports = require('./1.x');
}).call(this);

View File

@@ -0,0 +1,98 @@
// Generated by CoffeeScript 1.12.7
(function() {
var abstract_mapper, adapter_to_name, fs, get_version, glob, indx, match_version_to_adapter, name_to_adapter, path, resolve, resolve_engine_path, semver, supports;
path = require('path');
fs = require('fs');
glob = require('glob');
indx = require('indx');
resolve = require('resolve');
semver = require('semver');
exports.supports = supports = function(name) {
name = adapter_to_name(name);
return !!glob.sync("" + (path.join(__dirname, 'adapters', name))).length;
};
exports.load = function(name, custom_path, engine_name) {
var adapter_name, engine_path, version;
name = adapter_to_name(name);
engine_path = resolve_engine_path(name, custom_path);
version = get_version(engine_path);
adapter_name = match_version_to_adapter(name, version);
if (!adapter_name) {
throw new Error(name + " version " + version + " is not currently supported");
}
return new (require(adapter_name))(engine_name, engine_path);
};
exports.all = function() {
return indx(path.join(__dirname, 'adapters'));
};
exports.abstract_mapper = abstract_mapper = function(name, direction) {
var name_maps, res;
name_maps = [['markdown', 'marked'], ['minify-js', 'uglify-js'], ['minify-css', 'clean-css'], ['minify-html', 'html-minifier'], ['mustache', 'hogan.js'], ['scss', 'node-sass'], ['haml', 'hamljs'], ['escape-html', 'he'], ['jsx', 'react-tools'], ['cjsx', 'coffee-react-transform'], ['babel', 'babel-core'], ['typescript', 'typescript-compiler']];
res = null;
name_maps.forEach(function(n) {
if (direction === 'left' && n[0] === name) {
res = n[1];
}
if (direction === 'right' && n[1] === name) {
return res = n[0];
}
});
return res || name;
};
exports.adapter_to_name = adapter_to_name = function(name) {
return abstract_mapper(name, 'right');
};
exports.name_to_adapter = name_to_adapter = function(name) {
return abstract_mapper(name, 'left');
};
resolve_engine_path = function(name, custom_path) {
var filepath;
filepath = custom_path != null ? resolve.sync(name_to_adapter(name), {
basedir: custom_path
}) : require.resolve(name_to_adapter(name));
while (true) {
if (filepath === '/') {
throw new Error("cannot resolve root of node module " + name);
}
filepath = path.dirname(filepath);
if (fs.existsSync(path.join(filepath, 'package.json'))) {
return filepath;
}
}
};
get_version = function(engine_path) {
var err;
try {
return require(engine_path + '/package.json').version;
} catch (error) {
err = error;
}
};
match_version_to_adapter = function(name, version) {
var adapter, adapters, i, len;
adapters = fs.readdirSync(path.join(__dirname, 'adapters', name));
for (i = 0, len = adapters.length; i < len; i++) {
adapter = adapters[i];
adapter = adapter.replace(/\.(?:js|coffee)$/, '');
if (semver.satisfies(version, adapter)) {
return path.join(__dirname, 'adapters', name, adapter);
}
}
};
}).call(this);

View File

@@ -0,0 +1,34 @@
// Generated by CoffeeScript 1.12.7
(function() {
var W, fs, node;
W = require('when');
node = require('when/node');
fs = require('fs');
/**
* Reads a source map's sources and inlines them in the `sourcesContents` key,
* returning the full map.
*
* @param {Object} map - source map v3
* @return {Promise} a promise for the sourcemap updated with contents
*/
exports.inline_sources = function(map) {
if (map.sourcesContent) {
return W.resolve(map);
}
return W.map(map.sources, function(source) {
return node.call(fs.readFile.bind(fs), source, 'utf8');
}).then(function(contents) {
map.sourcesContent = contents;
return map;
})["catch"](function() {
return map;
});
};
}).call(this);

10
node_modules/gulp-less/node_modules/accord/license.md generated vendored Normal file
View File

@@ -0,0 +1,10 @@
License (MIT)
-------------
Copyright (c) 2013 Jeff Escalante
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1 @@
../semver/bin/semver

View File

@@ -0,0 +1 @@
../uglify-js/bin/uglifyjs

View File

@@ -0,0 +1,23 @@
Copyright 2013 Thorsten Lorenz.
All rights reserved.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,125 @@
# convert-source-map [![build status](https://secure.travis-ci.org/thlorenz/convert-source-map.png)](http://travis-ci.org/thlorenz/convert-source-map)
[![NPM](https://nodei.co/npm/convert-source-map.png?downloads=true&stars=true)](https://nodei.co/npm/convert-source-map/)
Converts a source-map from/to different formats and allows adding/changing properties.
```js
var convert = require('convert-source-map');
var json = convert
.fromComment('//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGQvZm9vLm1pbi5qcyIsInNvdXJjZXMiOlsic3JjL2Zvby5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=')
.toJSON();
var modified = convert
.fromComment('//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGQvZm9vLm1pbi5qcyIsInNvdXJjZXMiOlsic3JjL2Zvby5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=')
.setProperty('sources', [ 'SRC/FOO.JS' ])
.toJSON();
console.log(json);
console.log(modified);
```
```json
{"version":3,"file":"build/foo.min.js","sources":["src/foo.js"],"names":[],"mappings":"AAAA","sourceRoot":"/"}
{"version":3,"file":"build/foo.min.js","sources":["SRC/FOO.JS"],"names":[],"mappings":"AAAA","sourceRoot":"/"}
```
## API
### fromObject(obj)
Returns source map converter from given object.
### fromJSON(json)
Returns source map converter from given json string.
### fromBase64(base64)
Returns source map converter from given base64 encoded json string.
### fromComment(comment)
Returns source map converter from given base64 encoded json string prefixed with `//# sourceMappingURL=...`.
### fromMapFileComment(comment, mapFileDir)
Returns source map converter from given `filename` by parsing `//# sourceMappingURL=filename`.
`filename` must point to a file that is found inside the `mapFileDir`. Most tools store this file right next to the
generated file, i.e. the one containing the source map.
### fromSource(source)
Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was found.
### fromMapFileSource(source, mapFileDir)
Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was
found.
The sourcemap will be read from the map file found by parsing `# sourceMappingURL=file` comment. For more info see
fromMapFileComment.
### toObject()
Returns a copy of the underlying source map.
### toJSON([space])
Converts source map to json string. If `space` is given (optional), this will be passed to
[JSON.stringify](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/stringify) when the
JSON string is generated.
### toBase64()
Converts source map to base64 encoded json string.
### toComment([options])
Converts source map to an inline comment that can be appended to the source-file.
By default, the comment is formatted like: `//# sourceMappingURL=...`, which you would
normally see in a JS source file.
When `options.multiline == true`, the comment is formatted like: `/*# sourceMappingURL=... */`, which you would find in a CSS source file.
### addProperty(key, value)
Adds given property to the source map. Throws an error if property already exists.
### setProperty(key, value)
Sets given property to the source map. If property doesn't exist it is added, otherwise its value is updated.
### getProperty(key)
Gets given property of the source map.
### removeComments(src)
Returns `src` with all source map comments removed
### removeMapFileComments(src)
Returns `src` with all source map comments pointing to map files removed.
### commentRegex
Provides __a fresh__ RegExp each time it is accessed. Can be used to find source map comments.
### mapFileCommentRegex
Provides __a fresh__ RegExp each time it is accessed. Can be used to find source map comments pointing to map files.
### generateMapFileComment(file, [options])
Returns a comment that links to an external source map via `file`.
By default, the comment is formatted like: `//# sourceMappingURL=...`, which you would normally see in a JS source file.
When `options.multiline == true`, the comment is formatted like: `/*# sourceMappingURL=... */`, which you would find in a CSS source file.
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/thlorenz/convert-source-map/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

View File

@@ -0,0 +1,135 @@
'use strict';
var fs = require('fs');
var path = require('path');
Object.defineProperty(exports, 'commentRegex', {
get: function getCommentRegex () {
return /^\s*\/(?:\/|\*)[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/mg;
}
});
Object.defineProperty(exports, 'mapFileCommentRegex', {
get: function getMapFileCommentRegex () {
// Matches sourceMappingURL in either // or /* comment styles.
return /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"`]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg;
}
});
function decodeBase64(base64) {
return new Buffer(base64, 'base64').toString();
}
function stripComment(sm) {
return sm.split(',').pop();
}
function readFromFileMap(sm, dir) {
// NOTE: this will only work on the server since it attempts to read the map file
var r = exports.mapFileCommentRegex.exec(sm);
// for some odd reason //# .. captures in 1 and /* .. */ in 2
var filename = r[1] || r[2];
var filepath = path.resolve(dir, filename);
try {
return fs.readFileSync(filepath, 'utf8');
} catch (e) {
throw new Error('An error occurred while trying to read the map file at ' + filepath + '\n' + e);
}
}
function Converter (sm, opts) {
opts = opts || {};
if (opts.isFileComment) sm = readFromFileMap(sm, opts.commentFileDir);
if (opts.hasComment) sm = stripComment(sm);
if (opts.isEncoded) sm = decodeBase64(sm);
if (opts.isJSON || opts.isEncoded) sm = JSON.parse(sm);
this.sourcemap = sm;
}
Converter.prototype.toJSON = function (space) {
return JSON.stringify(this.sourcemap, null, space);
};
Converter.prototype.toBase64 = function () {
var json = this.toJSON();
return new Buffer(json).toString('base64');
};
Converter.prototype.toComment = function (options) {
var base64 = this.toBase64();
var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
};
// returns copy instead of original
Converter.prototype.toObject = function () {
return JSON.parse(this.toJSON());
};
Converter.prototype.addProperty = function (key, value) {
if (this.sourcemap.hasOwnProperty(key)) throw new Error('property "' + key + '" already exists on the sourcemap, use set property instead');
return this.setProperty(key, value);
};
Converter.prototype.setProperty = function (key, value) {
this.sourcemap[key] = value;
return this;
};
Converter.prototype.getProperty = function (key) {
return this.sourcemap[key];
};
exports.fromObject = function (obj) {
return new Converter(obj);
};
exports.fromJSON = function (json) {
return new Converter(json, { isJSON: true });
};
exports.fromBase64 = function (base64) {
return new Converter(base64, { isEncoded: true });
};
exports.fromComment = function (comment) {
comment = comment
.replace(/^\/\*/g, '//')
.replace(/\*\/$/g, '');
return new Converter(comment, { isEncoded: true, hasComment: true });
};
exports.fromMapFileComment = function (comment, dir) {
return new Converter(comment, { commentFileDir: dir, isFileComment: true, isJSON: true });
};
// Finds last sourcemap comment in file or returns null if none was found
exports.fromSource = function (content) {
var m = content.match(exports.commentRegex);
return m ? exports.fromComment(m.pop()) : null;
};
// Finds last sourcemap comment in file or returns null if none was found
exports.fromMapFileSource = function (content, dir) {
var m = content.match(exports.mapFileCommentRegex);
return m ? exports.fromMapFileComment(m.pop(), dir) : null;
};
exports.removeComments = function (src) {
return src.replace(exports.commentRegex, '');
};
exports.removeMapFileComments = function (src) {
return src.replace(exports.mapFileCommentRegex, '');
};
exports.generateMapFileComment = function (file, options) {
var data = 'sourceMappingURL=' + file;
return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
};

View File

@@ -0,0 +1,68 @@
{
"name": "convert-source-map",
"version": "1.5.1",
"description": "Converts a source-map from/to different formats and allows adding/changing properties.",
"main": "index.js",
"scripts": {
"test": "tap test/*.js --color"
},
"repository": {
"type": "git",
"url": "git://github.com/thlorenz/convert-source-map.git"
},
"homepage": "https://github.com/thlorenz/convert-source-map",
"dependencies": {},
"devDependencies": {
"inline-source-map": "~0.6.2",
"tap": "~9.0.0"
},
"keywords": [
"convert",
"sourcemap",
"source",
"map",
"browser",
"debug"
],
"author": {
"name": "Thorsten Lorenz",
"email": "thlorenz@gmx.de",
"url": "http://thlorenz.com"
},
"license": "MIT",
"engine": {
"node": ">=0.6"
},
"files": [
"index.js"
],
"gitHead": "0771098071f3b7c48ec6604291cad28b3b679d02",
"bugs": {
"url": "https://github.com/thlorenz/convert-source-map/issues"
},
"_id": "convert-source-map@1.5.1",
"_shasum": "b8278097b9bc229365de5c62cf5fcaed8b5599e5",
"_from": "convert-source-map@>=1.5.0 <2.0.0",
"_npmVersion": "2.15.12",
"_nodeVersion": "8.9.1",
"_npmUser": {
"name": "thlorenz",
"email": "thlorenz@gmx.de"
},
"dist": {
"shasum": "b8278097b9bc229365de5c62cf5fcaed8b5599e5",
"tarball": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz"
},
"maintainers": [
{
"name": "thlorenz",
"email": "thlorenz@gmx.de"
}
],
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/convert-source-map-1.5.1.tgz_1511432397773_0.3238030842039734"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz"
}

View File

@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@@ -0,0 +1,368 @@
# Glob
Match files using the patterns the shell uses, like stars and stuff.
[![Build Status](https://travis-ci.org/isaacs/node-glob.svg?branch=master)](https://travis-ci.org/isaacs/node-glob/) [![Build Status](https://ci.appveyor.com/api/projects/status/kd7f3yftf7unxlsx?svg=true)](https://ci.appveyor.com/project/isaacs/node-glob) [![Coverage Status](https://coveralls.io/repos/isaacs/node-glob/badge.svg?branch=master&service=github)](https://coveralls.io/github/isaacs/node-glob?branch=master)
This is a glob implementation in JavaScript. It uses the `minimatch`
library to do its matching.
![](oh-my-glob.gif)
## Usage
Install with npm
```
npm i glob
```
```javascript
var glob = require("glob")
// options is optional
glob("**/*.js", options, function (er, files) {
// files is an array of filenames.
// If the `nonull` option is set, and nothing
// was found, then files is ["**/*.js"]
// er is an error object or null.
})
```
## Glob Primer
"Globs" are the patterns you type when you do stuff like `ls *.js` on
the command line, or put `build/*` in a `.gitignore` file.
Before parsing the path part patterns, braced sections are expanded
into a set. Braced sections start with `{` and end with `}`, with any
number of comma-delimited sections within. Braced sections may contain
slash characters, so `a{/b/c,bcd}` would expand into `a/b/c` and `abcd`.
The following characters have special magic meaning when used in a
path portion:
* `*` Matches 0 or more characters in a single path portion
* `?` Matches 1 character
* `[...]` Matches a range of characters, similar to a RegExp range.
If the first character of the range is `!` or `^` then it matches
any character not in the range.
* `!(pattern|pattern|pattern)` Matches anything that does not match
any of the patterns provided.
* `?(pattern|pattern|pattern)` Matches zero or one occurrence of the
patterns provided.
* `+(pattern|pattern|pattern)` Matches one or more occurrences of the
patterns provided.
* `*(a|b|c)` Matches zero or more occurrences of the patterns provided
* `@(pattern|pat*|pat?erN)` Matches exactly one of the patterns
provided
* `**` If a "globstar" is alone in a path portion, then it matches
zero or more directories and subdirectories searching for matches.
It does not crawl symlinked directories.
### Dots
If a file or directory path portion has a `.` as the first character,
then it will not match any glob pattern unless that pattern's
corresponding path part also has a `.` as its first character.
For example, the pattern `a/.*/c` would match the file at `a/.b/c`.
However the pattern `a/*/c` would not, because `*` does not start with
a dot character.
You can make glob treat dots as normal characters by setting
`dot:true` in the options.
### Basename Matching
If you set `matchBase:true` in the options, and the pattern has no
slashes in it, then it will seek for any file anywhere in the tree
with a matching basename. For example, `*.js` would match
`test/simple/basic.js`.
### Empty Sets
If no matching files are found, then an empty array is returned. This
differs from the shell, where the pattern itself is returned. For
example:
$ echo a*s*d*f
a*s*d*f
To get the bash-style behavior, set the `nonull:true` in the options.
### See Also:
* `man sh`
* `man bash` (Search for "Pattern Matching")
* `man 3 fnmatch`
* `man 5 gitignore`
* [minimatch documentation](https://github.com/isaacs/minimatch)
## glob.hasMagic(pattern, [options])
Returns `true` if there are any special characters in the pattern, and
`false` otherwise.
Note that the options affect the results. If `noext:true` is set in
the options object, then `+(a|b)` will not be considered a magic
pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}`
then that is considered magical, unless `nobrace:true` is set in the
options.
## glob(pattern, [options], cb)
* `pattern` `{String}` Pattern to be matched
* `options` `{Object}`
* `cb` `{Function}`
* `err` `{Error | null}`
* `matches` `{Array<String>}` filenames found matching the pattern
Perform an asynchronous glob search.
## glob.sync(pattern, [options])
* `pattern` `{String}` Pattern to be matched
* `options` `{Object}`
* return: `{Array<String>}` filenames found matching the pattern
Perform a synchronous glob search.
## Class: glob.Glob
Create a Glob object by instantiating the `glob.Glob` class.
```javascript
var Glob = require("glob").Glob
var mg = new Glob(pattern, options, cb)
```
It's an EventEmitter, and starts walking the filesystem to find matches
immediately.
### new glob.Glob(pattern, [options], [cb])
* `pattern` `{String}` pattern to search for
* `options` `{Object}`
* `cb` `{Function}` Called when an error occurs, or matches are found
* `err` `{Error | null}`
* `matches` `{Array<String>}` filenames found matching the pattern
Note that if the `sync` flag is set in the options, then matches will
be immediately available on the `g.found` member.
### Properties
* `minimatch` The minimatch object that the glob uses.
* `options` The options object passed in.
* `aborted` Boolean which is set to true when calling `abort()`. There
is no way at this time to continue a glob search after aborting, but
you can re-use the statCache to avoid having to duplicate syscalls.
* `cache` Convenience object. Each field has the following possible
values:
* `false` - Path does not exist
* `true` - Path exists
* `'FILE'` - Path exists, and is not a directory
* `'DIR'` - Path exists, and is a directory
* `[file, entries, ...]` - Path exists, is a directory, and the
array value is the results of `fs.readdir`
* `statCache` Cache of `fs.stat` results, to prevent statting the same
path multiple times.
* `symlinks` A record of which paths are symbolic links, which is
relevant in resolving `**` patterns.
* `realpathCache` An optional object which is passed to `fs.realpath`
to minimize unnecessary syscalls. It is stored on the instantiated
Glob object, and may be re-used.
### Events
* `end` When the matching is finished, this is emitted with all the
matches found. If the `nonull` option is set, and no match was found,
then the `matches` list contains the original pattern. The matches
are sorted, unless the `nosort` flag is set.
* `match` Every time a match is found, this is emitted with the specific
thing that matched. It is not deduplicated or resolved to a realpath.
* `error` Emitted when an unexpected error is encountered, or whenever
any fs error occurs if `options.strict` is set.
* `abort` When `abort()` is called, this event is raised.
### Methods
* `pause` Temporarily stop the search
* `resume` Resume the search
* `abort` Stop the search forever
### Options
All the options that can be passed to Minimatch can also be passed to
Glob to change pattern matching behavior. Also, some have been added,
or have glob-specific ramifications.
All options are false by default, unless otherwise noted.
All options are added to the Glob object, as well.
If you are running many `glob` operations, you can pass a Glob object
as the `options` argument to a subsequent operation to shortcut some
`stat` and `readdir` calls. At the very least, you may pass in shared
`symlinks`, `statCache`, `realpathCache`, and `cache` options, so that
parallel glob operations will be sped up by sharing information about
the filesystem.
* `cwd` The current working directory in which to search. Defaults
to `process.cwd()`.
* `root` The place where patterns starting with `/` will be mounted
onto. Defaults to `path.resolve(options.cwd, "/")` (`/` on Unix
systems, and `C:\` or some such on Windows.)
* `dot` Include `.dot` files in normal matches and `globstar` matches.
Note that an explicit dot in a portion of the pattern will always
match dot files.
* `nomount` By default, a pattern starting with a forward-slash will be
"mounted" onto the root setting, so that a valid filesystem path is
returned. Set this flag to disable that behavior.
* `mark` Add a `/` character to directory matches. Note that this
requires additional stat calls.
* `nosort` Don't sort the results.
* `stat` Set to true to stat *all* results. This reduces performance
somewhat, and is completely unnecessary, unless `readdir` is presumed
to be an untrustworthy indicator of file existence.
* `silent` When an unusual error is encountered when attempting to
read a directory, a warning will be printed to stderr. Set the
`silent` option to true to suppress these warnings.
* `strict` When an unusual error is encountered when attempting to
read a directory, the process will just continue on in search of
other matches. Set the `strict` option to raise an error in these
cases.
* `cache` See `cache` property above. Pass in a previously generated
cache object to save some fs calls.
* `statCache` A cache of results of filesystem information, to prevent
unnecessary stat calls. While it should not normally be necessary
to set this, you may pass the statCache from one glob() call to the
options object of another, if you know that the filesystem will not
change between calls. (See "Race Conditions" below.)
* `symlinks` A cache of known symbolic links. You may pass in a
previously generated `symlinks` object to save `lstat` calls when
resolving `**` matches.
* `sync` DEPRECATED: use `glob.sync(pattern, opts)` instead.
* `nounique` In some cases, brace-expanded patterns can result in the
same file showing up multiple times in the result set. By default,
this implementation prevents duplicates in the result set. Set this
flag to disable that behavior.
* `nonull` Set to never return an empty set, instead returning a set
containing the pattern itself. This is the default in glob(3).
* `debug` Set to enable debug logging in minimatch and glob.
* `nobrace` Do not expand `{a,b}` and `{1..3}` brace sets.
* `noglobstar` Do not match `**` against multiple filenames. (Ie,
treat it as a normal `*` instead.)
* `noext` Do not match `+(a|b)` "extglob" patterns.
* `nocase` Perform a case-insensitive match. Note: on
case-insensitive filesystems, non-magic patterns will match by
default, since `stat` and `readdir` will not raise errors.
* `matchBase` Perform a basename-only match if the pattern does not
contain any slash characters. That is, `*.js` would be treated as
equivalent to `**/*.js`, matching all js files in all directories.
* `nodir` Do not match directories, only files. (Note: to match
*only* directories, simply put a `/` at the end of the pattern.)
* `ignore` Add a pattern or an array of glob patterns to exclude matches.
Note: `ignore` patterns are *always* in `dot:true` mode, regardless
of any other settings.
* `follow` Follow symlinked directories when expanding `**` patterns.
Note that this can result in a lot of duplicate references in the
presence of cyclic links.
* `realpath` Set to true to call `fs.realpath` on all of the results.
In the case of a symlink that cannot be resolved, the full absolute
path to the matched entry is returned (though it will usually be a
broken symlink)
* `absolute` Set to true to always receive absolute paths for matched
files. Unlike `realpath`, this also affects the values returned in
the `match` event.
## Comparisons to other fnmatch/glob implementations
While strict compliance with the existing standards is a worthwhile
goal, some discrepancies exist between node-glob and other
implementations, and are intentional.
The double-star character `**` is supported by default, unless the
`noglobstar` flag is set. This is supported in the manner of bsdglob
and bash 4.3, where `**` only has special significance if it is the only
thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but
`a/**b` will not.
Note that symlinked directories are not crawled as part of a `**`,
though their contents may match against subsequent portions of the
pattern. This prevents infinite loops and duplicates and the like.
If an escaped pattern has no matches, and the `nonull` flag is set,
then glob returns the pattern as-provided, rather than
interpreting the character escapes. For example,
`glob.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
`"*a?"`. This is akin to setting the `nullglob` option in bash, except
that it does not resolve escaped pattern characters.
If brace expansion is not disabled, then it is performed before any
other interpretation of the glob pattern. Thus, a pattern like
`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded
**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are
checked for validity. Since those two are valid, matching proceeds.
### Comments and Negation
Previously, this module let you mark a pattern as a "comment" if it
started with a `#` character, or a "negated" pattern if it started
with a `!` character.
These options were deprecated in version 5, and removed in version 6.
To specify things that should not match, use the `ignore` option.
## Windows
**Please only use forward-slashes in glob expressions.**
Though windows uses either `/` or `\` as its path separator, only `/`
characters are used by this glob implementation. You must use
forward-slashes **only** in glob expressions. Back-slashes will always
be interpreted as escape characters, not path separators.
Results from absolute patterns such as `/foo/*` are mounted onto the
root setting using `path.join`. On windows, this will by default result
in `/foo/*` matching `C:\foo\bar.txt`.
## Race Conditions
Glob searching, by its very nature, is susceptible to race conditions,
since it relies on directory walking and such.
As a result, it is possible that a file that exists when glob looks for
it may have been deleted or modified by the time it returns the result.
As part of its internal implementation, this program caches all stat
and readdir calls that it makes, in order to cut down on system
overhead. However, this also makes it even more susceptible to races,
especially if the cache or statCache objects are reused between glob
calls.
Users are thus advised not to use a glob result as a guarantee of
filesystem state in the face of rapid changes. For the vast majority
of operations, this is never a problem.
## Contributing
Any change to behavior (including bugfixes) must come with a test.
Patches that fail tests or reduce performance will be rejected.
```
# to run tests
npm test
# to re-generate test fixtures
npm run test-regen
# to benchmark against bash/zsh
npm run bench
# to profile javascript
npm run prof
```

View File

@@ -0,0 +1,67 @@
## 7.0
- Raise error if `options.cwd` is specified, and not a directory
## 6.0
- Remove comment and negation pattern support
- Ignore patterns are always in `dot:true` mode
## 5.0
- Deprecate comment and negation patterns
- Fix regression in `mark` and `nodir` options from making all cache
keys absolute path.
- Abort if `fs.readdir` returns an error that's unexpected
- Don't emit `match` events for ignored items
- Treat ENOTSUP like ENOTDIR in readdir
## 4.5
- Add `options.follow` to always follow directory symlinks in globstar
- Add `options.realpath` to call `fs.realpath` on all results
- Always cache based on absolute path
## 4.4
- Add `options.ignore`
- Fix handling of broken symlinks
## 4.3
- Bump minimatch to 2.x
- Pass all tests on Windows
## 4.2
- Add `glob.hasMagic` function
- Add `options.nodir` flag
## 4.1
- Refactor sync and async implementations for performance
- Throw if callback provided to sync glob function
- Treat symbolic links in globstar results the same as Bash 4.3
## 4.0
- Use `^` for dependency versions (bumped major because this breaks
older npm versions)
- Ensure callbacks are only ever called once
- switch to ISC license
## 3.x
- Rewrite in JavaScript
- Add support for setting root, cwd, and windows support
- Cache many fs calls
- Add globstar support
- emit match events
## 2.x
- Use `glob.h` and `fnmatch.h` from NetBSD
## 1.x
- `glob.h` static binding.

View File

@@ -0,0 +1,240 @@
exports.alphasort = alphasort
exports.alphasorti = alphasorti
exports.setopts = setopts
exports.ownProp = ownProp
exports.makeAbs = makeAbs
exports.finish = finish
exports.mark = mark
exports.isIgnored = isIgnored
exports.childrenIgnored = childrenIgnored
function ownProp (obj, field) {
return Object.prototype.hasOwnProperty.call(obj, field)
}
var path = require("path")
var minimatch = require("minimatch")
var isAbsolute = require("path-is-absolute")
var Minimatch = minimatch.Minimatch
function alphasorti (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase())
}
function alphasort (a, b) {
return a.localeCompare(b)
}
function setupIgnores (self, options) {
self.ignore = options.ignore || []
if (!Array.isArray(self.ignore))
self.ignore = [self.ignore]
if (self.ignore.length) {
self.ignore = self.ignore.map(ignoreMap)
}
}
// ignore patterns are always in dot:true mode.
function ignoreMap (pattern) {
var gmatcher = null
if (pattern.slice(-3) === '/**') {
var gpattern = pattern.replace(/(\/\*\*)+$/, '')
gmatcher = new Minimatch(gpattern, { dot: true })
}
return {
matcher: new Minimatch(pattern, { dot: true }),
gmatcher: gmatcher
}
}
function setopts (self, pattern, options) {
if (!options)
options = {}
// base-matching: just use globstar for that.
if (options.matchBase && -1 === pattern.indexOf("/")) {
if (options.noglobstar) {
throw new Error("base matching requires globstar")
}
pattern = "**/" + pattern
}
self.silent = !!options.silent
self.pattern = pattern
self.strict = options.strict !== false
self.realpath = !!options.realpath
self.realpathCache = options.realpathCache || Object.create(null)
self.follow = !!options.follow
self.dot = !!options.dot
self.mark = !!options.mark
self.nodir = !!options.nodir
if (self.nodir)
self.mark = true
self.sync = !!options.sync
self.nounique = !!options.nounique
self.nonull = !!options.nonull
self.nosort = !!options.nosort
self.nocase = !!options.nocase
self.stat = !!options.stat
self.noprocess = !!options.noprocess
self.absolute = !!options.absolute
self.maxLength = options.maxLength || Infinity
self.cache = options.cache || Object.create(null)
self.statCache = options.statCache || Object.create(null)
self.symlinks = options.symlinks || Object.create(null)
setupIgnores(self, options)
self.changedCwd = false
var cwd = process.cwd()
if (!ownProp(options, "cwd"))
self.cwd = cwd
else {
self.cwd = path.resolve(options.cwd)
self.changedCwd = self.cwd !== cwd
}
self.root = options.root || path.resolve(self.cwd, "/")
self.root = path.resolve(self.root)
if (process.platform === "win32")
self.root = self.root.replace(/\\/g, "/")
// TODO: is an absolute `cwd` supposed to be resolved against `root`?
// e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd)
if (process.platform === "win32")
self.cwdAbs = self.cwdAbs.replace(/\\/g, "/")
self.nomount = !!options.nomount
// disable comments and negation in Minimatch.
// Note that they are not supported in Glob itself anyway.
options.nonegate = true
options.nocomment = true
self.minimatch = new Minimatch(pattern, options)
self.options = self.minimatch.options
}
function finish (self) {
var nou = self.nounique
var all = nou ? [] : Object.create(null)
for (var i = 0, l = self.matches.length; i < l; i ++) {
var matches = self.matches[i]
if (!matches || Object.keys(matches).length === 0) {
if (self.nonull) {
// do like the shell, and spit out the literal glob
var literal = self.minimatch.globSet[i]
if (nou)
all.push(literal)
else
all[literal] = true
}
} else {
// had matches
var m = Object.keys(matches)
if (nou)
all.push.apply(all, m)
else
m.forEach(function (m) {
all[m] = true
})
}
}
if (!nou)
all = Object.keys(all)
if (!self.nosort)
all = all.sort(self.nocase ? alphasorti : alphasort)
// at *some* point we statted all of these
if (self.mark) {
for (var i = 0; i < all.length; i++) {
all[i] = self._mark(all[i])
}
if (self.nodir) {
all = all.filter(function (e) {
var notDir = !(/\/$/.test(e))
var c = self.cache[e] || self.cache[makeAbs(self, e)]
if (notDir && c)
notDir = c !== 'DIR' && !Array.isArray(c)
return notDir
})
}
}
if (self.ignore.length)
all = all.filter(function(m) {
return !isIgnored(self, m)
})
self.found = all
}
function mark (self, p) {
var abs = makeAbs(self, p)
var c = self.cache[abs]
var m = p
if (c) {
var isDir = c === 'DIR' || Array.isArray(c)
var slash = p.slice(-1) === '/'
if (isDir && !slash)
m += '/'
else if (!isDir && slash)
m = m.slice(0, -1)
if (m !== p) {
var mabs = makeAbs(self, m)
self.statCache[mabs] = self.statCache[abs]
self.cache[mabs] = self.cache[abs]
}
}
return m
}
// lotta situps...
function makeAbs (self, f) {
var abs = f
if (f.charAt(0) === '/') {
abs = path.join(self.root, f)
} else if (isAbsolute(f) || f === '') {
abs = f
} else if (self.changedCwd) {
abs = path.resolve(self.cwd, f)
} else {
abs = path.resolve(f)
}
if (process.platform === 'win32')
abs = abs.replace(/\\/g, '/')
return abs
}
// Return true, if pattern ends with globstar '**', for the accompanying parent directory.
// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
function isIgnored (self, path) {
if (!self.ignore.length)
return false
return self.ignore.some(function(item) {
return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path))
})
}
function childrenIgnored (self, path) {
if (!self.ignore.length)
return false
return self.ignore.some(function(item) {
return !!(item.gmatcher && item.gmatcher.match(path))
})
}

View File

@@ -0,0 +1,790 @@
// Approach:
//
// 1. Get the minimatch set
// 2. For each pattern in the set, PROCESS(pattern, false)
// 3. Store matches per-set, then uniq them
//
// PROCESS(pattern, inGlobStar)
// Get the first [n] items from pattern that are all strings
// Join these together. This is PREFIX.
// If there is no more remaining, then stat(PREFIX) and
// add to matches if it succeeds. END.
//
// If inGlobStar and PREFIX is symlink and points to dir
// set ENTRIES = []
// else readdir(PREFIX) as ENTRIES
// If fail, END
//
// with ENTRIES
// If pattern[n] is GLOBSTAR
// // handle the case where the globstar match is empty
// // by pruning it out, and testing the resulting pattern
// PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
// // handle other cases.
// for ENTRY in ENTRIES (not dotfiles)
// // attach globstar + tail onto the entry
// // Mark that this entry is a globstar match
// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
//
// else // not globstar
// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
// Test ENTRY against pattern[n]
// If fails, continue
// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
//
// Caveat:
// Cache all stats and readdirs results to minimize syscall. Since all
// we ever care about is existence and directory-ness, we can just keep
// `true` for files, and [children,...] for directories, or `false` for
// things that don't exist.
module.exports = glob
var fs = require('fs')
var rp = require('fs.realpath')
var minimatch = require('minimatch')
var Minimatch = minimatch.Minimatch
var inherits = require('inherits')
var EE = require('events').EventEmitter
var path = require('path')
var assert = require('assert')
var isAbsolute = require('path-is-absolute')
var globSync = require('./sync.js')
var common = require('./common.js')
var alphasort = common.alphasort
var alphasorti = common.alphasorti
var setopts = common.setopts
var ownProp = common.ownProp
var inflight = require('inflight')
var util = require('util')
var childrenIgnored = common.childrenIgnored
var isIgnored = common.isIgnored
var once = require('once')
function glob (pattern, options, cb) {
if (typeof options === 'function') cb = options, options = {}
if (!options) options = {}
if (options.sync) {
if (cb)
throw new TypeError('callback provided to sync glob')
return globSync(pattern, options)
}
return new Glob(pattern, options, cb)
}
glob.sync = globSync
var GlobSync = glob.GlobSync = globSync.GlobSync
// old api surface
glob.glob = glob
function extend (origin, add) {
if (add === null || typeof add !== 'object') {
return origin
}
var keys = Object.keys(add)
var i = keys.length
while (i--) {
origin[keys[i]] = add[keys[i]]
}
return origin
}
glob.hasMagic = function (pattern, options_) {
var options = extend({}, options_)
options.noprocess = true
var g = new Glob(pattern, options)
var set = g.minimatch.set
if (!pattern)
return false
if (set.length > 1)
return true
for (var j = 0; j < set[0].length; j++) {
if (typeof set[0][j] !== 'string')
return true
}
return false
}
glob.Glob = Glob
inherits(Glob, EE)
function Glob (pattern, options, cb) {
if (typeof options === 'function') {
cb = options
options = null
}
if (options && options.sync) {
if (cb)
throw new TypeError('callback provided to sync glob')
return new GlobSync(pattern, options)
}
if (!(this instanceof Glob))
return new Glob(pattern, options, cb)
setopts(this, pattern, options)
this._didRealPath = false
// process each pattern in the minimatch set
var n = this.minimatch.set.length
// The matches are stored as {<filename>: true,...} so that
// duplicates are automagically pruned.
// Later, we do an Object.keys() on these.
// Keep them as a list so we can fill in when nonull is set.
this.matches = new Array(n)
if (typeof cb === 'function') {
cb = once(cb)
this.on('error', cb)
this.on('end', function (matches) {
cb(null, matches)
})
}
var self = this
this._processing = 0
this._emitQueue = []
this._processQueue = []
this.paused = false
if (this.noprocess)
return this
if (n === 0)
return done()
var sync = true
for (var i = 0; i < n; i ++) {
this._process(this.minimatch.set[i], i, false, done)
}
sync = false
function done () {
--self._processing
if (self._processing <= 0) {
if (sync) {
process.nextTick(function () {
self._finish()
})
} else {
self._finish()
}
}
}
}
Glob.prototype._finish = function () {
assert(this instanceof Glob)
if (this.aborted)
return
if (this.realpath && !this._didRealpath)
return this._realpath()
common.finish(this)
this.emit('end', this.found)
}
Glob.prototype._realpath = function () {
if (this._didRealpath)
return
this._didRealpath = true
var n = this.matches.length
if (n === 0)
return this._finish()
var self = this
for (var i = 0; i < this.matches.length; i++)
this._realpathSet(i, next)
function next () {
if (--n === 0)
self._finish()
}
}
Glob.prototype._realpathSet = function (index, cb) {
var matchset = this.matches[index]
if (!matchset)
return cb()
var found = Object.keys(matchset)
var self = this
var n = found.length
if (n === 0)
return cb()
var set = this.matches[index] = Object.create(null)
found.forEach(function (p, i) {
// If there's a problem with the stat, then it means that
// one or more of the links in the realpath couldn't be
// resolved. just return the abs value in that case.
p = self._makeAbs(p)
rp.realpath(p, self.realpathCache, function (er, real) {
if (!er)
set[real] = true
else if (er.syscall === 'stat')
set[p] = true
else
self.emit('error', er) // srsly wtf right here
if (--n === 0) {
self.matches[index] = set
cb()
}
})
})
}
Glob.prototype._mark = function (p) {
return common.mark(this, p)
}
Glob.prototype._makeAbs = function (f) {
return common.makeAbs(this, f)
}
Glob.prototype.abort = function () {
this.aborted = true
this.emit('abort')
}
Glob.prototype.pause = function () {
if (!this.paused) {
this.paused = true
this.emit('pause')
}
}
Glob.prototype.resume = function () {
if (this.paused) {
this.emit('resume')
this.paused = false
if (this._emitQueue.length) {
var eq = this._emitQueue.slice(0)
this._emitQueue.length = 0
for (var i = 0; i < eq.length; i ++) {
var e = eq[i]
this._emitMatch(e[0], e[1])
}
}
if (this._processQueue.length) {
var pq = this._processQueue.slice(0)
this._processQueue.length = 0
for (var i = 0; i < pq.length; i ++) {
var p = pq[i]
this._processing--
this._process(p[0], p[1], p[2], p[3])
}
}
}
}
Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
assert(this instanceof Glob)
assert(typeof cb === 'function')
if (this.aborted)
return
this._processing++
if (this.paused) {
this._processQueue.push([pattern, index, inGlobStar, cb])
return
}
//console.error('PROCESS %d', this._processing, pattern)
// Get the first [n] parts of pattern that are all strings.
var n = 0
while (typeof pattern[n] === 'string') {
n ++
}
// now n is the index of the first one that is *not* a string.
// see if there's anything else
var prefix
switch (n) {
// if not, then this is rather simple
case pattern.length:
this._processSimple(pattern.join('/'), index, cb)
return
case 0:
// pattern *starts* with some non-trivial item.
// going to readdir(cwd), but not include the prefix in matches.
prefix = null
break
default:
// pattern has some string bits in the front.
// whatever it starts with, whether that's 'absolute' like /foo/bar,
// or 'relative' like '../baz'
prefix = pattern.slice(0, n).join('/')
break
}
var remain = pattern.slice(n)
// get the list of entries.
var read
if (prefix === null)
read = '.'
else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
if (!prefix || !isAbsolute(prefix))
prefix = '/' + prefix
read = prefix
} else
read = prefix
var abs = this._makeAbs(read)
//if ignored, skip _processing
if (childrenIgnored(this, read))
return cb()
var isGlobStar = remain[0] === minimatch.GLOBSTAR
if (isGlobStar)
this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb)
else
this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb)
}
Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
var self = this
this._readdir(abs, inGlobStar, function (er, entries) {
return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
})
}
Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
// if the abs isn't a dir, then nothing can match!
if (!entries)
return cb()
// It will only match dot entries if it starts with a dot, or if
// dot is set. Stuff like @(.foo|.bar) isn't allowed.
var pn = remain[0]
var negate = !!this.minimatch.negate
var rawGlob = pn._glob
var dotOk = this.dot || rawGlob.charAt(0) === '.'
var matchedEntries = []
for (var i = 0; i < entries.length; i++) {
var e = entries[i]
if (e.charAt(0) !== '.' || dotOk) {
var m
if (negate && !prefix) {
m = !e.match(pn)
} else {
m = e.match(pn)
}
if (m)
matchedEntries.push(e)
}
}
//console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
var len = matchedEntries.length
// If there are no matched entries, then nothing matches.
if (len === 0)
return cb()
// if this is the last remaining pattern bit, then no need for
// an additional stat *unless* the user has specified mark or
// stat explicitly. We know they exist, since readdir returned
// them.
if (remain.length === 1 && !this.mark && !this.stat) {
if (!this.matches[index])
this.matches[index] = Object.create(null)
for (var i = 0; i < len; i ++) {
var e = matchedEntries[i]
if (prefix) {
if (prefix !== '/')
e = prefix + '/' + e
else
e = prefix + e
}
if (e.charAt(0) === '/' && !this.nomount) {
e = path.join(this.root, e)
}
this._emitMatch(index, e)
}
// This was the last one, and no stats were needed
return cb()
}
// now test all matched entries as stand-ins for that part
// of the pattern.
remain.shift()
for (var i = 0; i < len; i ++) {
var e = matchedEntries[i]
var newPattern
if (prefix) {
if (prefix !== '/')
e = prefix + '/' + e
else
e = prefix + e
}
this._process([e].concat(remain), index, inGlobStar, cb)
}
cb()
}
Glob.prototype._emitMatch = function (index, e) {
if (this.aborted)
return
if (isIgnored(this, e))
return
if (this.paused) {
this._emitQueue.push([index, e])
return
}
var abs = isAbsolute(e) ? e : this._makeAbs(e)
if (this.mark)
e = this._mark(e)
if (this.absolute)
e = abs
if (this.matches[index][e])
return
if (this.nodir) {
var c = this.cache[abs]
if (c === 'DIR' || Array.isArray(c))
return
}
this.matches[index][e] = true
var st = this.statCache[abs]
if (st)
this.emit('stat', e, st)
this.emit('match', e)
}
Glob.prototype._readdirInGlobStar = function (abs, cb) {
if (this.aborted)
return
// follow all symlinked directories forever
// just proceed as if this is a non-globstar situation
if (this.follow)
return this._readdir(abs, false, cb)
var lstatkey = 'lstat\0' + abs
var self = this
var lstatcb = inflight(lstatkey, lstatcb_)
if (lstatcb)
fs.lstat(abs, lstatcb)
function lstatcb_ (er, lstat) {
if (er && er.code === 'ENOENT')
return cb()
var isSym = lstat && lstat.isSymbolicLink()
self.symlinks[abs] = isSym
// If it's not a symlink or a dir, then it's definitely a regular file.
// don't bother doing a readdir in that case.
if (!isSym && lstat && !lstat.isDirectory()) {
self.cache[abs] = 'FILE'
cb()
} else
self._readdir(abs, false, cb)
}
}
Glob.prototype._readdir = function (abs, inGlobStar, cb) {
if (this.aborted)
return
cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb)
if (!cb)
return
//console.error('RD %j %j', +inGlobStar, abs)
if (inGlobStar && !ownProp(this.symlinks, abs))
return this._readdirInGlobStar(abs, cb)
if (ownProp(this.cache, abs)) {
var c = this.cache[abs]
if (!c || c === 'FILE')
return cb()
if (Array.isArray(c))
return cb(null, c)
}
var self = this
fs.readdir(abs, readdirCb(this, abs, cb))
}
function readdirCb (self, abs, cb) {
return function (er, entries) {
if (er)
self._readdirError(abs, er, cb)
else
self._readdirEntries(abs, entries, cb)
}
}
Glob.prototype._readdirEntries = function (abs, entries, cb) {
if (this.aborted)
return
// if we haven't asked to stat everything, then just
// assume that everything in there exists, so we can avoid
// having to stat it a second time.
if (!this.mark && !this.stat) {
for (var i = 0; i < entries.length; i ++) {
var e = entries[i]
if (abs === '/')
e = abs + e
else
e = abs + '/' + e
this.cache[e] = true
}
}
this.cache[abs] = entries
return cb(null, entries)
}
Glob.prototype._readdirError = function (f, er, cb) {
if (this.aborted)
return
// handle errors, and cache the information
switch (er.code) {
case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
case 'ENOTDIR': // totally normal. means it *does* exist.
var abs = this._makeAbs(f)
this.cache[abs] = 'FILE'
if (abs === this.cwdAbs) {
var error = new Error(er.code + ' invalid cwd ' + this.cwd)
error.path = this.cwd
error.code = er.code
this.emit('error', error)
this.abort()
}
break
case 'ENOENT': // not terribly unusual
case 'ELOOP':
case 'ENAMETOOLONG':
case 'UNKNOWN':
this.cache[this._makeAbs(f)] = false
break
default: // some unusual error. Treat as failure.
this.cache[this._makeAbs(f)] = false
if (this.strict) {
this.emit('error', er)
// If the error is handled, then we abort
// if not, we threw out of here
this.abort()
}
if (!this.silent)
console.error('glob error', er)
break
}
return cb()
}
Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
var self = this
this._readdir(abs, inGlobStar, function (er, entries) {
self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
})
}
Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
//console.error('pgs2', prefix, remain[0], entries)
// no entries means not a dir, so it can never have matches
// foo.txt/** doesn't match foo.txt
if (!entries)
return cb()
// test without the globstar, and with every child both below
// and replacing the globstar.
var remainWithoutGlobStar = remain.slice(1)
var gspref = prefix ? [ prefix ] : []
var noGlobStar = gspref.concat(remainWithoutGlobStar)
// the noGlobStar pattern exits the inGlobStar state
this._process(noGlobStar, index, false, cb)
var isSym = this.symlinks[abs]
var len = entries.length
// If it's a symlink, and we're in a globstar, then stop
if (isSym && inGlobStar)
return cb()
for (var i = 0; i < len; i++) {
var e = entries[i]
if (e.charAt(0) === '.' && !this.dot)
continue
// these two cases enter the inGlobStar state
var instead = gspref.concat(entries[i], remainWithoutGlobStar)
this._process(instead, index, true, cb)
var below = gspref.concat(entries[i], remain)
this._process(below, index, true, cb)
}
cb()
}
Glob.prototype._processSimple = function (prefix, index, cb) {
// XXX review this. Shouldn't it be doing the mounting etc
// before doing stat? kinda weird?
var self = this
this._stat(prefix, function (er, exists) {
self._processSimple2(prefix, index, er, exists, cb)
})
}
Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
//console.error('ps2', prefix, exists)
if (!this.matches[index])
this.matches[index] = Object.create(null)
// If it doesn't exist, then just mark the lack of results
if (!exists)
return cb()
if (prefix && isAbsolute(prefix) && !this.nomount) {
var trail = /[\/\\]$/.test(prefix)
if (prefix.charAt(0) === '/') {
prefix = path.join(this.root, prefix)
} else {
prefix = path.resolve(this.root, prefix)
if (trail)
prefix += '/'
}
}
if (process.platform === 'win32')
prefix = prefix.replace(/\\/g, '/')
// Mark this as a match
this._emitMatch(index, prefix)
cb()
}
// Returns either 'DIR', 'FILE', or false
Glob.prototype._stat = function (f, cb) {
var abs = this._makeAbs(f)
var needDir = f.slice(-1) === '/'
if (f.length > this.maxLength)
return cb()
if (!this.stat && ownProp(this.cache, abs)) {
var c = this.cache[abs]
if (Array.isArray(c))
c = 'DIR'
// It exists, but maybe not how we need it
if (!needDir || c === 'DIR')
return cb(null, c)
if (needDir && c === 'FILE')
return cb()
// otherwise we have to stat, because maybe c=true
// if we know it exists, but not what it is.
}
var exists
var stat = this.statCache[abs]
if (stat !== undefined) {
if (stat === false)
return cb(null, stat)
else {
var type = stat.isDirectory() ? 'DIR' : 'FILE'
if (needDir && type === 'FILE')
return cb()
else
return cb(null, type, stat)
}
}
var self = this
var statcb = inflight('stat\0' + abs, lstatcb_)
if (statcb)
fs.lstat(abs, statcb)
function lstatcb_ (er, lstat) {
if (lstat && lstat.isSymbolicLink()) {
// If it's a symlink, then treat it as the target, unless
// the target does not exist, then treat it as a file.
return fs.stat(abs, function (er, stat) {
if (er)
self._stat2(f, abs, null, lstat, cb)
else
self._stat2(f, abs, er, stat, cb)
})
} else {
self._stat2(f, abs, er, lstat, cb)
}
}
}
Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
this.statCache[abs] = false
return cb()
}
var needDir = f.slice(-1) === '/'
this.statCache[abs] = stat
if (abs.slice(-1) === '/' && stat && !stat.isDirectory())
return cb(null, false, stat)
var c = true
if (stat)
c = stat.isDirectory() ? 'DIR' : 'FILE'
this.cache[abs] = this.cache[abs] || c
if (needDir && c === 'FILE')
return cb()
return cb(null, c, stat)
}

View File

@@ -0,0 +1,43 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
----
This library bundles a version of the `fs.realpath` and `fs.realpathSync`
methods from Node.js v0.10 under the terms of the Node.js MIT license.
Node's license follows, also included at the header of `old.js` which contains
the licensed code:
Copyright Joyent, Inc. and other Node contributors.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,33 @@
# fs.realpath
A backwards-compatible fs.realpath for Node v6 and above
In Node v6, the JavaScript implementation of fs.realpath was replaced
with a faster (but less resilient) native implementation. That raises
new and platform-specific errors and cannot handle long or excessively
symlink-looping paths.
This module handles those cases by detecting the new errors and
falling back to the JavaScript implementation. On versions of Node
prior to v6, it has no effect.
## USAGE
```js
var rp = require('fs.realpath')
// async version
rp.realpath(someLongAndLoopingPath, function (er, real) {
// the ELOOP was handled, but it was a bit slower
})
// sync version
var real = rp.realpathSync(someLongAndLoopingPath)
// monkeypatch at your own risk!
// This replaces the fs.realpath/fs.realpathSync builtins
rp.monkeypatch()
// un-do the monkeypatching
rp.unmonkeypatch()
```

View File

@@ -0,0 +1,66 @@
module.exports = realpath
realpath.realpath = realpath
realpath.sync = realpathSync
realpath.realpathSync = realpathSync
realpath.monkeypatch = monkeypatch
realpath.unmonkeypatch = unmonkeypatch
var fs = require('fs')
var origRealpath = fs.realpath
var origRealpathSync = fs.realpathSync
var version = process.version
var ok = /^v[0-5]\./.test(version)
var old = require('./old.js')
function newError (er) {
return er && er.syscall === 'realpath' && (
er.code === 'ELOOP' ||
er.code === 'ENOMEM' ||
er.code === 'ENAMETOOLONG'
)
}
function realpath (p, cache, cb) {
if (ok) {
return origRealpath(p, cache, cb)
}
if (typeof cache === 'function') {
cb = cache
cache = null
}
origRealpath(p, cache, function (er, result) {
if (newError(er)) {
old.realpath(p, cache, cb)
} else {
cb(er, result)
}
})
}
function realpathSync (p, cache) {
if (ok) {
return origRealpathSync(p, cache)
}
try {
return origRealpathSync(p, cache)
} catch (er) {
if (newError(er)) {
return old.realpathSync(p, cache)
} else {
throw er
}
}
}
function monkeypatch () {
fs.realpath = realpath
fs.realpathSync = realpathSync
}
function unmonkeypatch () {
fs.realpath = origRealpath
fs.realpathSync = origRealpathSync
}

View File

@@ -0,0 +1,303 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var pathModule = require('path');
var isWindows = process.platform === 'win32';
var fs = require('fs');
// JavaScript implementation of realpath, ported from node pre-v6
var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
function rethrow() {
// Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
// is fairly slow to generate.
var callback;
if (DEBUG) {
var backtrace = new Error;
callback = debugCallback;
} else
callback = missingCallback;
return callback;
function debugCallback(err) {
if (err) {
backtrace.message = err.message;
err = backtrace;
missingCallback(err);
}
}
function missingCallback(err) {
if (err) {
if (process.throwDeprecation)
throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
else if (!process.noDeprecation) {
var msg = 'fs: missing callback ' + (err.stack || err.message);
if (process.traceDeprecation)
console.trace(msg);
else
console.error(msg);
}
}
}
}
function maybeCallback(cb) {
return typeof cb === 'function' ? cb : rethrow();
}
var normalize = pathModule.normalize;
// Regexp that finds the next partion of a (partial) path
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
if (isWindows) {
var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
} else {
var nextPartRe = /(.*?)(?:[\/]+|$)/g;
}
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
if (isWindows) {
var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
} else {
var splitRootRe = /^[\/]*/;
}
exports.realpathSync = function realpathSync(p, cache) {
// make p is absolute
p = pathModule.resolve(p);
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
return cache[p];
}
var original = p,
seenLinks = {},
knownHard = {};
// current character position in p
var pos;
// the partial path so far, including a trailing slash if any
var current;
// the partial path without a trailing slash (except when pointing at a root)
var base;
// the partial path scanned in the previous round, with slash
var previous;
start();
function start() {
// Skip over roots
var m = splitRootRe.exec(p);
pos = m[0].length;
current = m[0];
base = m[0];
previous = '';
// On windows, check that the root exists. On unix there is no need.
if (isWindows && !knownHard[base]) {
fs.lstatSync(base);
knownHard[base] = true;
}
}
// walk down the path, swapping out linked pathparts for their real
// values
// NB: p.length changes.
while (pos < p.length) {
// find the next part
nextPartRe.lastIndex = pos;
var result = nextPartRe.exec(p);
previous = current;
current += result[0];
base = previous + result[1];
pos = nextPartRe.lastIndex;
// continue if not a symlink
if (knownHard[base] || (cache && cache[base] === base)) {
continue;
}
var resolvedLink;
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
// some known symbolic link. no need to stat again.
resolvedLink = cache[base];
} else {
var stat = fs.lstatSync(base);
if (!stat.isSymbolicLink()) {
knownHard[base] = true;
if (cache) cache[base] = base;
continue;
}
// read the link if it wasn't read before
// dev/ino always return 0 on windows, so skip the check.
var linkTarget = null;
if (!isWindows) {
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
if (seenLinks.hasOwnProperty(id)) {
linkTarget = seenLinks[id];
}
}
if (linkTarget === null) {
fs.statSync(base);
linkTarget = fs.readlinkSync(base);
}
resolvedLink = pathModule.resolve(previous, linkTarget);
// track this, if given a cache.
if (cache) cache[base] = resolvedLink;
if (!isWindows) seenLinks[id] = linkTarget;
}
// resolve the link, then start over
p = pathModule.resolve(resolvedLink, p.slice(pos));
start();
}
if (cache) cache[original] = p;
return p;
};
exports.realpath = function realpath(p, cache, cb) {
if (typeof cb !== 'function') {
cb = maybeCallback(cache);
cache = null;
}
// make p is absolute
p = pathModule.resolve(p);
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
return process.nextTick(cb.bind(null, null, cache[p]));
}
var original = p,
seenLinks = {},
knownHard = {};
// current character position in p
var pos;
// the partial path so far, including a trailing slash if any
var current;
// the partial path without a trailing slash (except when pointing at a root)
var base;
// the partial path scanned in the previous round, with slash
var previous;
start();
function start() {
// Skip over roots
var m = splitRootRe.exec(p);
pos = m[0].length;
current = m[0];
base = m[0];
previous = '';
// On windows, check that the root exists. On unix there is no need.
if (isWindows && !knownHard[base]) {
fs.lstat(base, function(err) {
if (err) return cb(err);
knownHard[base] = true;
LOOP();
});
} else {
process.nextTick(LOOP);
}
}
// walk down the path, swapping out linked pathparts for their real
// values
function LOOP() {
// stop if scanned past end of path
if (pos >= p.length) {
if (cache) cache[original] = p;
return cb(null, p);
}
// find the next part
nextPartRe.lastIndex = pos;
var result = nextPartRe.exec(p);
previous = current;
current += result[0];
base = previous + result[1];
pos = nextPartRe.lastIndex;
// continue if not a symlink
if (knownHard[base] || (cache && cache[base] === base)) {
return process.nextTick(LOOP);
}
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
// known symbolic link. no need to stat again.
return gotResolvedLink(cache[base]);
}
return fs.lstat(base, gotStat);
}
function gotStat(err, stat) {
if (err) return cb(err);
// if not a symlink, skip to the next path part
if (!stat.isSymbolicLink()) {
knownHard[base] = true;
if (cache) cache[base] = base;
return process.nextTick(LOOP);
}
// stat & read the link if not read before
// call gotTarget as soon as the link target is known
// dev/ino always return 0 on windows, so skip the check.
if (!isWindows) {
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
if (seenLinks.hasOwnProperty(id)) {
return gotTarget(null, seenLinks[id], base);
}
}
fs.stat(base, function(err) {
if (err) return cb(err);
fs.readlink(base, function(err, target) {
if (!isWindows) seenLinks[id] = target;
gotTarget(err, target);
});
});
}
function gotTarget(err, target, base) {
if (err) return cb(err);
var resolvedLink = pathModule.resolve(previous, target);
if (cache) cache[base] = resolvedLink;
gotResolvedLink(resolvedLink);
}
function gotResolvedLink(resolvedLink) {
// resolve the link, then start over
p = pathModule.resolve(resolvedLink, p.slice(pos));
start();
}
};

View File

@@ -0,0 +1,60 @@
{
"name": "fs.realpath",
"version": "1.0.0",
"description": "Use node's fs.realpath, but fall back to the JS implementation if the native one fails",
"main": "index.js",
"dependencies": {},
"devDependencies": {},
"scripts": {
"test": "tap test/*.js --cov"
},
"repository": {
"type": "git",
"url": "git+https://github.com/isaacs/fs.realpath.git"
},
"keywords": [
"realpath",
"fs",
"polyfill"
],
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"license": "ISC",
"files": [
"old.js",
"index.js"
],
"gitHead": "03e7c884431fe185dfebbc9b771aeca339c1807a",
"bugs": {
"url": "https://github.com/isaacs/fs.realpath/issues"
},
"homepage": "https://github.com/isaacs/fs.realpath#readme",
"_id": "fs.realpath@1.0.0",
"_shasum": "1504ad2523158caa40db4a2787cb01411994ea4f",
"_from": "fs.realpath@>=1.0.0 <2.0.0",
"_npmVersion": "3.9.1",
"_nodeVersion": "4.4.4",
"_npmUser": {
"name": "isaacs",
"email": "i@izs.me"
},
"dist": {
"shasum": "1504ad2523158caa40db4a2787cb01411994ea4f",
"tarball": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
},
"maintainers": [
{
"name": "isaacs",
"email": "i@izs.me"
}
],
"_npmOperationalInternal": {
"host": "packages-16-east.internal.npmjs.com",
"tmp": "tmp/fs.realpath-1.0.0.tgz_1466015941059_0.3332864767871797"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
}

View File

@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@@ -0,0 +1,37 @@
# inflight
Add callbacks to requests in flight to avoid async duplication
## USAGE
```javascript
var inflight = require('inflight')
// some request that does some stuff
function req(key, callback) {
// key is any random string. like a url or filename or whatever.
//
// will return either a falsey value, indicating that the
// request for this key is already in flight, or a new callback
// which when called will call all callbacks passed to inflightk
// with the same key
callback = inflight(key, callback)
// If we got a falsey value back, then there's already a req going
if (!callback) return
// this is where you'd fetch the url or whatever
// callback is also once()-ified, so it can safely be assigned
// to multiple events etc. First call wins.
setTimeout(function() {
callback(null, key)
}, 100)
}
// only assigns a single setTimeout
// when it dings, all cbs get called
req('foo', cb1)
req('foo', cb2)
req('foo', cb3)
req('foo', cb4)
```

View File

@@ -0,0 +1,54 @@
var wrappy = require('wrappy')
var reqs = Object.create(null)
var once = require('once')
module.exports = wrappy(inflight)
function inflight (key, cb) {
if (reqs[key]) {
reqs[key].push(cb)
return null
} else {
reqs[key] = [cb]
return makeres(key)
}
}
function makeres (key) {
return once(function RES () {
var cbs = reqs[key]
var len = cbs.length
var args = slice(arguments)
// XXX It's somewhat ambiguous whether a new callback added in this
// pass should be queued for later execution if something in the
// list of callbacks throws, or if it should just be discarded.
// However, it's such an edge case that it hardly matters, and either
// choice is likely as surprising as the other.
// As it happens, we do go ahead and schedule it for later execution.
try {
for (var i = 0; i < len; i++) {
cbs[i].apply(null, args)
}
} finally {
if (cbs.length > len) {
// added more in the interim.
// de-zalgo, just in case, but don't call again.
cbs.splice(0, len)
process.nextTick(function () {
RES.apply(null, args)
})
} else {
delete reqs[key]
}
}
})
}
function slice (args) {
var length = args.length
var array = []
for (var i = 0; i < length; i++) array[i] = args[i]
return array
}

View File

@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Some files were not shown because too many files have changed in this diff Show More