mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-10 21:01:41 +00:00
update
This commit is contained in:
1
node_modules/detective-stylus/.npmignore
generated
vendored
Normal file
1
node_modules/detective-stylus/.npmignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
25
node_modules/detective-stylus/Readme.md
generated
vendored
Normal file
25
node_modules/detective-stylus/Readme.md
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
### detective-stylus [](https://npmjs.org/package/detective-stylus) [](https://npmjs.org/package/detective-stylus)
|
||||
|
||||
> Find the dependencies of a Stylus file
|
||||
|
||||
`npm install detective-stylus`
|
||||
|
||||
It's the Stylus counterpart to
|
||||
[detective](https://github.com/substack/node-detective),
|
||||
[detective-amd](https://github.com/mrjoelkemp/node-detective-amd),
|
||||
[detective-es6](https://github.com/mrjoelkemp/node-detective-es6),
|
||||
and [detective-sass](https://github.com/mrjoelkemp/node-detective-sass)
|
||||
|
||||
Note: this detective uses a regex to find the `@import` or `@require` statements.
|
||||
|
||||
### Usage
|
||||
|
||||
```js
|
||||
var detective = require('detective-stylus');
|
||||
|
||||
var content = fs.readFileSync('styles.styl', 'utf8');
|
||||
|
||||
// list of imported file names (ex: '_foo.styl', '_foo', etc)
|
||||
var dependencies = detective(content);
|
||||
```
|
||||
|
26
node_modules/detective-stylus/index.js
generated
vendored
Normal file
26
node_modules/detective-stylus/index.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Extract the @import/@require statements from a given stylus file's content
|
||||
*
|
||||
* @param {String} fileContent
|
||||
* @return {String[]}
|
||||
*/
|
||||
module.exports = function(fileContent) {
|
||||
if (typeof fileContent === 'undefined') { throw new Error('content not given'); }
|
||||
if (typeof fileContent !== 'string') { throw new Error('content is not a string'); }
|
||||
|
||||
var dependencies = [];
|
||||
var importRegex = /\@(import|require)\s['"](.*)['"](\.styl)?/g;
|
||||
|
||||
var matches;
|
||||
|
||||
do {
|
||||
matches = importRegex.exec(fileContent);
|
||||
|
||||
if (matches) {
|
||||
dependencies.push(matches[2]);
|
||||
}
|
||||
|
||||
} while (matches);
|
||||
|
||||
return dependencies;
|
||||
};
|
61
node_modules/detective-stylus/package.json
generated
vendored
Normal file
61
node_modules/detective-stylus/package.json
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"detective-stylus@1.0.0",
|
||||
"/Users/tatiana/selfdefined"
|
||||
]
|
||||
],
|
||||
"_from": "detective-stylus@1.0.0",
|
||||
"_id": "detective-stylus@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-UK7n24uruZA4HwEMY/q7pbWOVM0=",
|
||||
"_location": "/detective-stylus",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "detective-stylus@1.0.0",
|
||||
"name": "detective-stylus",
|
||||
"escapedName": "detective-stylus",
|
||||
"rawSpec": "1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/precinct"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/detective-stylus/-/detective-stylus-1.0.0.tgz",
|
||||
"_spec": "1.0.0",
|
||||
"_where": "/Users/tatiana/selfdefined",
|
||||
"author": {
|
||||
"name": "Joel Kemp",
|
||||
"email": "joel@mrjoelkemp.com",
|
||||
"url": "http://www.mrjoelkemp.com/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mrjoelkemp/node-detective-stylus/issues"
|
||||
},
|
||||
"description": "Get the dependencies of a Stylus file",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"homepage": "https://github.com/mrjoelkemp/node-detective-stylus",
|
||||
"keywords": [
|
||||
"stylus",
|
||||
"ast",
|
||||
"static",
|
||||
"analysis",
|
||||
"dependencies"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "detective-stylus",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mrjoelkemp/node-detective-stylus.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
29
node_modules/detective-stylus/test/test.js
generated
vendored
Normal file
29
node_modules/detective-stylus/test/test.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
var detective = require('../');
|
||||
var assert = require('assert');
|
||||
|
||||
describe('detective-stylus', function() {
|
||||
function hasDependencies(source, expected) {
|
||||
var deps = detective(source);
|
||||
assert.deepEqual(deps, expected);
|
||||
}
|
||||
|
||||
it('returns the dependencies of Stylus @import statements', function() {
|
||||
hasDependencies('@import "_foo.styl"', ['_foo.styl']);
|
||||
hasDependencies('@import "_foo"', ['_foo']);
|
||||
hasDependencies('body { color: blue } @import "_foo"', ['_foo']);
|
||||
hasDependencies('@import "bar"', ['bar']);
|
||||
hasDependencies('@import "_foo.styl";\n@import "_bar.styl"', ['_foo.styl', '_bar.styl']);
|
||||
hasDependencies('@import "_foo.styl"\n@import "_bar.styl"\n@import "_baz"\n@import "_buttons"', ['_foo.styl', '_bar.styl', '_baz', '_buttons']);
|
||||
});
|
||||
|
||||
it('returns the dependencies of Stylus @require statements', function() {
|
||||
hasDependencies('@require \'bar\';', ['bar']);
|
||||
hasDependencies('@require \'bar.styl\';', ['bar.styl']);
|
||||
});
|
||||
|
||||
it('does not throw for empty files', function() {
|
||||
assert.doesNotThrow(function() {
|
||||
detective('');
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user