summaryrefslogtreecommitdiffstats
path: root/node_modules/sass-graph/parse-imports.js
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/sass-graph/parse-imports.js
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'node_modules/sass-graph/parse-imports.js')
-rw-r--r--node_modules/sass-graph/parse-imports.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/node_modules/sass-graph/parse-imports.js b/node_modules/sass-graph/parse-imports.js
new file mode 100644
index 0000000..634253e
--- /dev/null
+++ b/node_modules/sass-graph/parse-imports.js
@@ -0,0 +1,64 @@
+var tokenizer = require('scss-tokenizer');
+
+function parseImports(content, isIndentedSyntax) {
+ var tokens = tokenizer.tokenize(content);
+ var results = [];
+ var tmp = '';
+ var inImport = false;
+ var inParen = false;
+ var prevToken = tokens[0];
+
+ var i, token;
+ for (i = 1; i < tokens.length; i++) {
+ token = tokens[i];
+
+ if (inImport && !inParen && token[0] === 'string') {
+ results.push(token[1]);
+ }
+ else if (token[1] === 'import' && prevToken[1] === '@') {
+ if (inImport && !isIndentedSyntax) {
+ throw new Error('Encountered invalid @import syntax.');
+ }
+
+ inImport = true;
+ }
+ else if (inImport && !inParen && (token[0] === 'ident' || token[0] === '/')) {
+ tmp += token[1];
+ }
+ else if (inImport && !inParen && (token[0] === 'space' || token[0] === 'newline')) {
+ if (tmp !== '') {
+ results.push(tmp);
+ tmp = '';
+
+ if (isIndentedSyntax) {
+ inImport = false;
+ }
+ }
+ }
+ else if (inImport && token[0] === ';') {
+ inImport = false;
+
+ if (tmp !== '') {
+ results.push(tmp);
+ tmp = '';
+ }
+ }
+ else if (inImport && token[0] === '(') {
+ inParen = true;
+ tmp = '';
+ }
+ else if (inParen && token[0] === ')') {
+ inParen = false;
+ }
+
+ prevToken = token;
+ }
+
+ if (tmp !== '') {
+ results.push(tmp);
+ }
+
+ return results;
+}
+
+module.exports = parseImports;