initial
This commit is contained in:
19
node_modules/pug-load/HISTORY.md
generated
vendored
Normal file
19
node_modules/pug-load/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
2.0.3 / 2016-08-24
|
||||
==================
|
||||
|
||||
* Do not pollute the user's `options` object
|
||||
|
||||
2.0.2 / 2016-08-23
|
||||
==================
|
||||
|
||||
* Only publish the module itself
|
||||
|
||||
2.0.1 / 2016-08-23
|
||||
==================
|
||||
|
||||
* Update to pug-walk@^1.0.0
|
||||
|
||||
2.0.0 / 2016-05-14
|
||||
==================
|
||||
|
||||
* Make filename part of the options - updates to the 2.x.y APIs for lexer and parser
|
||||
19
node_modules/pug-load/LICENSE
generated
vendored
Normal file
19
node_modules/pug-load/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2015 Forbes Lindesay
|
||||
|
||||
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.
|
||||
104
node_modules/pug-load/README.md
generated
vendored
Normal file
104
node_modules/pug-load/README.md
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
# pug-load
|
||||
|
||||
The pug loader is responsible for loading the depenendencies of a given pug file. It adds `fullPath` and `str` properties to every `Include` and `Extends` node. It also adds an `ast` property to any `Include` nodes that are loading pug and any `Extends` nodes. It then recursively loads the dependencies of any of those included files.
|
||||
|
||||
[](https://travis-ci.org/pugjs/pug-load)
|
||||
[](https://david-dm.org/pugjs/pug-load)
|
||||
[](https://www.npmjs.org/package/pug-load)
|
||||
[](https://codecov.io/gh/pugjs/pug-load)
|
||||
|
||||
## Installation
|
||||
|
||||
npm install pug-load
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var load = require('pug-load');
|
||||
```
|
||||
|
||||
### `load(ast, options)`
|
||||
### `load.string(str, filename, options)`
|
||||
### `load.file(filename, options)`
|
||||
|
||||
Loads all dependencies of the Pug AST. `load.string` and `load.file` are syntactic sugar that parses the string or file instead of you doing it yourself.
|
||||
|
||||
`options` may contain the following properties:
|
||||
|
||||
- `lex` (function): **(required)** the lexer used
|
||||
- `parse` (function): **(required)** the parser used
|
||||
- `resolve` (function): a function used to override `load.resolve`. Defaults to `load.resolve`.
|
||||
- `read` (function): a function used to override `load.read`. Defaults to `load.read`.
|
||||
- `basedir` (string): the base directory of absolute inclusion. This is **required** when absolute inclusion (file name starts with `'/'`) is used. Defaults to undefined.
|
||||
|
||||
The `options` object is passed to `load.resolve` and `load.read`, or equivalently `options.resolve` and `options.read`.
|
||||
|
||||
### `load.resolve(filename, source, options)`
|
||||
|
||||
Callback used by `pug-load` to resolve the full path of an included or extended file given the path of the source file.
|
||||
|
||||
`filename` is the included file. `source` is the name of the parent file that includes `filename`.
|
||||
|
||||
This function is not meant to be called from outside of `pug-load`, but rather for you to override.
|
||||
|
||||
### `load.read(filename, options)`
|
||||
|
||||
Callback used by `pug-load` to return the contents of a file.
|
||||
|
||||
`filename` is the file to read.
|
||||
|
||||
This function is not meant to be called from outside of `pug-load`, but rather for you to override.
|
||||
|
||||
### `load.validateOptions(options)`
|
||||
|
||||
Callback used `pug-load` to ensure the options object is valid. If your overriden `load.resolve` or `load.read` uses a different `options` scheme, you will need to override this function as well.
|
||||
|
||||
This function is not meant to be called from outside of `pug-load`, but rather for you to override.
|
||||
|
||||
### Example
|
||||
|
||||
```js
|
||||
var fs = require('fs');
|
||||
var lex = require('pug-lexer');
|
||||
var parse = require('pug-parser');
|
||||
var load = require('pug-load');
|
||||
|
||||
// you can do everything very manually
|
||||
|
||||
var str = fs.readFileSync('bar.pug', 'utf8');
|
||||
var ast = load(parse(lex(str, 'bar.pug'), 'bar.pug'), {
|
||||
lex: lex,
|
||||
parse: parse,
|
||||
resolve: function (filename, source, options) {
|
||||
console.log('"' + filename + '" file requested from "' + source + '".');
|
||||
return load.resolve(filename, source, options);
|
||||
}
|
||||
});
|
||||
|
||||
// or you can do all that in just two steps
|
||||
|
||||
var str = fs.readFileSync('bar.pug', 'utf8');
|
||||
var ast = load.string(str, 'bar.pug', {
|
||||
lex: lex,
|
||||
parse: parse,
|
||||
resolve: function (filename, source, options) {
|
||||
console.log('"' + filename + '" file requested from "' + source + '".');
|
||||
return load.resolve(filename, source, options);
|
||||
}
|
||||
});
|
||||
|
||||
// or you can do all that in only one step
|
||||
|
||||
var ast = load.file('bar.pug', {
|
||||
lex: lex,
|
||||
parse: parse,
|
||||
resolve: function (filename, source, options) {
|
||||
console.log('"' + filename + '" file requested from "' + source + '".');
|
||||
return load.resolve(filename, source, options);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
101
node_modules/pug-load/index.js
generated
vendored
Normal file
101
node_modules/pug-load/index.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var walk = require('pug-walk');
|
||||
var assign = require('object-assign');
|
||||
|
||||
module.exports = load;
|
||||
function load(ast, options) {
|
||||
options = getOptions(options);
|
||||
// clone the ast
|
||||
ast = JSON.parse(JSON.stringify(ast));
|
||||
return walk(ast, function (node) {
|
||||
if (node.str === undefined) {
|
||||
if (node.type === 'Include' || node.type === 'RawInclude' || node.type === 'Extends') {
|
||||
var file = node.file;
|
||||
if (file.type !== 'FileReference') {
|
||||
throw new Error('Expected file.type to be "FileReference"');
|
||||
}
|
||||
var path, str;
|
||||
try {
|
||||
path = options.resolve(file.path, file.filename, options);
|
||||
file.fullPath = path;
|
||||
str = options.read(path, options);
|
||||
} catch (ex) {
|
||||
ex.message += '\n at ' + node.filename + ' line ' + node.line;
|
||||
throw ex;
|
||||
}
|
||||
file.str = str;
|
||||
if (node.type === 'Extends' || node.type === 'Include') {
|
||||
file.ast = load.string(str, assign({}, options, {
|
||||
filename: path
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
load.string = function loadString(src, options) {
|
||||
options = assign(getOptions(options), {
|
||||
src: src
|
||||
});
|
||||
var tokens = options.lex(src, options);
|
||||
var ast = options.parse(tokens, options);
|
||||
return load(ast, options);
|
||||
};
|
||||
load.file = function loadFile(filename, options) {
|
||||
options = assign(getOptions(options), {
|
||||
filename: filename
|
||||
});
|
||||
var str = options.read(filename);
|
||||
return load.string(str, options);
|
||||
}
|
||||
|
||||
load.resolve = function resolve(filename, source, options) {
|
||||
filename = filename.trim();
|
||||
if (filename[0] !== '/' && !source)
|
||||
throw new Error('the "filename" option is required to use includes and extends with "relative" paths');
|
||||
|
||||
if (filename[0] === '/' && !options.basedir)
|
||||
throw new Error('the "basedir" option is required to use includes and extends with "absolute" paths');
|
||||
|
||||
filename = path.join(filename[0] === '/' ? options.basedir : path.dirname(source.trim()), filename);
|
||||
|
||||
return filename;
|
||||
};
|
||||
load.read = function read(filename, options) {
|
||||
return fs.readFileSync(filename, 'utf8');
|
||||
};
|
||||
|
||||
load.validateOptions = function validateOptions(options) {
|
||||
/* istanbul ignore if */
|
||||
if (typeof options !== 'object') {
|
||||
throw new TypeError('options must be an object');
|
||||
}
|
||||
/* istanbul ignore if */
|
||||
if (typeof options.lex !== 'function') {
|
||||
throw new TypeError('options.lex must be a function');
|
||||
}
|
||||
/* istanbul ignore if */
|
||||
if (typeof options.parse !== 'function') {
|
||||
throw new TypeError('options.parse must be a function');
|
||||
}
|
||||
/* istanbul ignore if */
|
||||
if (options.resolve && typeof options.resolve !== 'function') {
|
||||
throw new TypeError('options.resolve must be a function');
|
||||
}
|
||||
/* istanbul ignore if */
|
||||
if (options.read && typeof options.read !== 'function') {
|
||||
throw new TypeError('options.read must be a function');
|
||||
}
|
||||
};
|
||||
|
||||
function getOptions(options) {
|
||||
load.validateOptions(options);
|
||||
return assign({
|
||||
resolve: load.resolve,
|
||||
read: load.read
|
||||
}, options);
|
||||
}
|
||||
80
node_modules/pug-load/package.json
generated
vendored
Normal file
80
node_modules/pug-load/package.json
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"pug-load@^2.0.9",
|
||||
"C:\\Users\\Tom\\Documents\\Development\\bitsy-image-to-room\\node_modules\\pug"
|
||||
]
|
||||
],
|
||||
"_from": "pug-load@>=2.0.9 <3.0.0",
|
||||
"_id": "pug-load@2.0.9",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/pug-load",
|
||||
"_nodeVersion": "8.4.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "s3://npm-registry-packages",
|
||||
"tmp": "tmp/pug-load-2.0.9.tgz_1504711687492_0.863124281167984"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "forbes@lindesay.co.uk",
|
||||
"name": "forbeslindesay"
|
||||
},
|
||||
"_npmVersion": "5.3.0",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "pug-load",
|
||||
"raw": "pug-load@^2.0.9",
|
||||
"rawSpec": "^2.0.9",
|
||||
"scope": null,
|
||||
"spec": ">=2.0.9 <3.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/pug"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/pug-load/-/pug-load-2.0.9.tgz",
|
||||
"_shasum": "ee217c914cc1d9324d44b86c32d1df241d36de7a",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "pug-load@^2.0.9",
|
||||
"_where": "C:\\Users\\Tom\\Documents\\Development\\bitsy-image-to-room\\node_modules\\pug",
|
||||
"author": {
|
||||
"name": "ForbesLindesay"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/pugjs/pug-load/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"object-assign": "^4.1.0",
|
||||
"pug-walk": "^1.1.5"
|
||||
},
|
||||
"description": "The Pug loader is responsible for loading the depenendencies of a given Pug file.",
|
||||
"devDependencies": {
|
||||
"pug-lexer": "^3.1.0",
|
||||
"pug-parser": "^4.0.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"integrity": "sha512-BDdZOCru4mg+1MiZwRQZh25+NTRo/R6/qArrdWIf308rHtWA5N9kpoUskRe4H6FslaQujC+DigH9LqlBA4gf6Q==",
|
||||
"shasum": "ee217c914cc1d9324d44b86c32d1df241d36de7a",
|
||||
"tarball": "https://registry.npmjs.org/pug-load/-/pug-load-2.0.9.tgz"
|
||||
},
|
||||
"homepage": "https://github.com/pugjs/pug-load#readme",
|
||||
"keywords": [
|
||||
"pug"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "timothygu",
|
||||
"email": "timothygu99@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "pug-load",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/pugjs/pug-load.git"
|
||||
},
|
||||
"version": "2.0.9"
|
||||
}
|
||||
149
node_modules/pug-load/test/__snapshots__/index.test.js.snap
generated
vendored
Normal file
149
node_modules/pug-load/test/__snapshots__/index.test.js.snap
generated
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
exports[`test pug-load 1`] = `
|
||||
Object {
|
||||
"filename": "<dirname>/foo.pug",
|
||||
"line": 0,
|
||||
"nodes": Array [
|
||||
Object {
|
||||
"column": 1,
|
||||
"file": Object {
|
||||
"ast": Object {
|
||||
"filename": "<dirname>/bar.pug",
|
||||
"line": 0,
|
||||
"nodes": Array [
|
||||
Object {
|
||||
"column": 1,
|
||||
"filename": "<dirname>/bar.pug",
|
||||
"line": 1,
|
||||
"mode": "replace",
|
||||
"name": "bing",
|
||||
"nodes": Array [],
|
||||
"type": "NamedBlock",
|
||||
},
|
||||
],
|
||||
"type": "Block",
|
||||
},
|
||||
"column": 9,
|
||||
"filename": "<dirname>/foo.pug",
|
||||
"fullPath": "<dirname>/bar.pug",
|
||||
"line": 1,
|
||||
"path": "bar.pug",
|
||||
"str": "block bing
|
||||
",
|
||||
"type": "FileReference",
|
||||
},
|
||||
"filename": "<dirname>/foo.pug",
|
||||
"line": 1,
|
||||
"type": "Extends",
|
||||
},
|
||||
Object {
|
||||
"column": 1,
|
||||
"filename": "<dirname>/foo.pug",
|
||||
"line": 3,
|
||||
"mode": "replace",
|
||||
"name": "bing",
|
||||
"nodes": Array [
|
||||
Object {
|
||||
"block": Object {
|
||||
"filename": "<dirname>/foo.pug",
|
||||
"line": 4,
|
||||
"nodes": Array [],
|
||||
"type": "Block",
|
||||
},
|
||||
"column": 3,
|
||||
"file": Object {
|
||||
"ast": Object {
|
||||
"filename": "<dirname>/bing.pug",
|
||||
"line": 0,
|
||||
"nodes": Array [
|
||||
Object {
|
||||
"attributeBlocks": Array [],
|
||||
"attrs": Array [
|
||||
Object {
|
||||
"column": 1,
|
||||
"filename": "<basedir>/packages/pug-load/test/bing.pug",
|
||||
"line": 1,
|
||||
"mustEscape": false,
|
||||
"name": "class",
|
||||
"val": "\'bing\'",
|
||||
},
|
||||
],
|
||||
"block": Object {
|
||||
"filename": "<dirname>/bing.pug",
|
||||
"line": 1,
|
||||
"nodes": Array [
|
||||
Object {
|
||||
"column": 7,
|
||||
"filename": "<dirname>/bing.pug",
|
||||
"line": 1,
|
||||
"type": "Text",
|
||||
"val": "bong",
|
||||
},
|
||||
],
|
||||
"type": "Block",
|
||||
},
|
||||
"column": 1,
|
||||
"filename": "<dirname>/bing.pug",
|
||||
"isInline": false,
|
||||
"line": 1,
|
||||
"name": "div",
|
||||
"selfClosing": false,
|
||||
"type": "Tag",
|
||||
},
|
||||
],
|
||||
"type": "Block",
|
||||
},
|
||||
"column": 11,
|
||||
"filename": "<dirname>/foo.pug",
|
||||
"fullPath": "<dirname>/bing.pug",
|
||||
"line": 4,
|
||||
"path": "bing.pug",
|
||||
"str": ".bing bong
|
||||
",
|
||||
"type": "FileReference",
|
||||
},
|
||||
"filename": "<dirname>/foo.pug",
|
||||
"line": 4,
|
||||
"type": "Include",
|
||||
},
|
||||
Object {
|
||||
"attributeBlocks": Array [],
|
||||
"attrs": Array [],
|
||||
"block": Object {
|
||||
"filename": "<dirname>/foo.pug",
|
||||
"line": 5,
|
||||
"nodes": Array [
|
||||
Object {
|
||||
"column": 5,
|
||||
"file": Object {
|
||||
"column": 13,
|
||||
"filename": "<dirname>/foo.pug",
|
||||
"fullPath": "<dirname>/script.js",
|
||||
"line": 6,
|
||||
"path": "script.js",
|
||||
"str": "document.write(\'hello world!\');
|
||||
",
|
||||
"type": "FileReference",
|
||||
},
|
||||
"filename": "<dirname>/foo.pug",
|
||||
"filters": Array [],
|
||||
"line": 6,
|
||||
"type": "RawInclude",
|
||||
},
|
||||
],
|
||||
"type": "Block",
|
||||
},
|
||||
"column": 3,
|
||||
"filename": "<dirname>/foo.pug",
|
||||
"isInline": false,
|
||||
"line": 5,
|
||||
"name": "script",
|
||||
"selfClosing": false,
|
||||
"type": "Tag",
|
||||
},
|
||||
],
|
||||
"type": "NamedBlock",
|
||||
},
|
||||
],
|
||||
"type": "Block",
|
||||
}
|
||||
`;
|
||||
1
node_modules/pug-load/test/bar.pug
generated
vendored
Normal file
1
node_modules/pug-load/test/bar.pug
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
block bing
|
||||
1
node_modules/pug-load/test/bing.pug
generated
vendored
Normal file
1
node_modules/pug-load/test/bing.pug
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.bing bong
|
||||
6
node_modules/pug-load/test/foo.pug
generated
vendored
Normal file
6
node_modules/pug-load/test/foo.pug
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
extends bar.pug
|
||||
|
||||
block bing
|
||||
include bing.pug
|
||||
script
|
||||
include script.js
|
||||
24
node_modules/pug-load/test/index.test.js
generated
vendored
Normal file
24
node_modules/pug-load/test/index.test.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var assert = require('assert');
|
||||
var walk = require('pug-walk');
|
||||
var lex = require('pug-lexer');
|
||||
var parse = require('pug-parser');
|
||||
var load = require('../');
|
||||
|
||||
test('pug-load', () => {
|
||||
var filename = __dirname + '/foo.pug';
|
||||
var ast = load.file(filename, {
|
||||
lex: lex,
|
||||
parse: parse
|
||||
});
|
||||
|
||||
ast = walk(ast, function (node) {
|
||||
if (node.filename) node.filename = '<dirname>/' + path.basename(node.filename);
|
||||
if (node.fullPath) node.fullPath = '<dirname>/' + path.basename(node.fullPath);
|
||||
}, {includeDependencies: true});
|
||||
|
||||
expect(ast).toMatchSnapshot();
|
||||
});
|
||||
1
node_modules/pug-load/test/script.js
generated
vendored
Normal file
1
node_modules/pug-load/test/script.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
document.write('hello world!');
|
||||
Reference in New Issue
Block a user