mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-12-19 10:12:51 +00:00
update
This commit is contained in:
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;
|
||||
};
|
||||
Reference in New Issue
Block a user