Skip to content

Commit

Permalink
Move files
Browse files Browse the repository at this point in the history
  • Loading branch information
jgranstrom committed Jan 23, 2017
1 parent 648604e commit d4c9463
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 17 deletions.
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { renderSync } = require('./render');
const { extractSync } = require('./extract');
const { renderSync } = require('./lib/render');
const { extractSync } = require('./lib/extract');

exports.renderSync = renderSync;
exports.extractSync = extractSync;
Expand All @@ -8,8 +8,7 @@ const res = exports.renderSync({
file: require('path').join(__dirname, 'test.scss'),
});

/*console.log(require('util').inspect(res, { depth: null }));
console.log(res.css.toString());*/
console.log('vars', res.vars);

setInterval(() => {

Expand Down
11 changes: 1 addition & 10 deletions extract.js → lib/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ exports.extractSync = (rendered, { compileOptions = {} } = {}) => {

sass.renderSync(extractionCompileOptions);

console.log('extractionMap', require('util').inspect(extractionMap, { depth: null }));

const extractedVariables = {};

Object.keys(extractionMap).map(filename => {
Expand All @@ -74,12 +72,5 @@ exports.extractSync = (rendered, { compileOptions = {} } = {}) => {
});
});

console.log('extraction is', require('util').inspect(extractedVariables, { depth: null }));

// TODO: Globals overwrite eachother so it is possible to just keep a global result object with just one key per variable extracted and the value
// Don't have to worry about which file it's from, Maybe just include an array of sources: [] for each file referencing / declaring the variable,
// might have to do the same for expressions as they may differ

rendered.extracted = { a: 'hey' };
return rendered;
return extractedVariables;
}
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion parse.js → lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ function extractImplicitGlobals(data) {

let matches;
while(matches = REGEX_VARIABLE.exec(decontextifiedData)) {
console.log('matches is', matches);
const declaration = matches[1];
const expression = matches[2];
const declarationClean = declaration.replace('$', '');
Expand Down
4 changes: 2 additions & 2 deletions render.js → lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ const { extractSync } = require('./extract');

exports.renderSync = (compileOptions = {}) => {
const rendered = sass.renderSync(compileOptions);
const renderedWithExtracted = extractSync(rendered, { compileOptions })
return renderedWithExtracted;
rendered.vars = extractSync(rendered, { compileOptions })
return rendered;
}

0 comments on commit d4c9463

Please sign in to comment.