New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gulp-shopify-sass

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-shopify-sass - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

40

index.js

@@ -72,4 +72,4 @@ 'use strict';

return cb(new gutil.PluginError(
PLUGIN_NAME, error
));
PLUGIN_NAME, error
));
};

@@ -89,2 +89,4 @@

// TODO: add includePaths feature in options and relavent processer
// Ensure file's parent directory in the include path

@@ -99,4 +101,5 @@ if (opts.includePaths) {

// TDDO: enable sync option once async render is done. Only support renderSync for now
// if (sync === true) {
// opts.includePaths.unshift(path.dirname(file.path));
if (sync === true) {
//////////////////////////////

@@ -114,15 +117,12 @@ // Sync Sass render

// } else {
// //////////////////////////////
// // Async Sass render
// //////////////////////////////
// var callback = function(error, catFile) {
// if (error) {
// return errorM(error);
// }
// filePush(catFile);
// };
} else {
//////////////////////////////
// Async Sass render
//////////////////////////////
var callback = function(catFile) {
filePush(catFile);
};
// gulpShopifySass.compiler.render(opts, callback);
// }
gulpShopifySass.compiler.render(opts, callback, errorM);
}
//////////////////////////////

@@ -139,8 +139,6 @@ // gulpShopifySass main process END

// TDDO: enable sync option once async render is done. Only support renderSync for now
gulpShopifySass.sync = function sync(options) {
return gulpShopifySass(options, true);
};
// gulpShopifySass.sync = function sync(options) {
// return gulpShopifySass(options, true);
// };
//////////////////////////////

@@ -147,0 +145,0 @@ // Log errors nicely

@@ -39,3 +39,3 @@ /*

// context object represents node-sass environment
// options.context = { options: options, callback: cb };
options.context = { options: options, callback: cb };

@@ -101,3 +101,3 @@ return options;

} catch (e) {
return false
return false;
}

@@ -116,2 +116,3 @@ }

let pathAndName = dirReg.exec(file);
const filepath = pathAndName[1] || '';

@@ -159,7 +160,9 @@ let filename = pathAndName[2] || '';

// @param: {object} options
// @return: {boolean} async
function importReplacer (options, sync) {
function importReplacer (options) {
var rex = /@import\s*(?:(?:'([^']+)')|(?:"([^"]+)"))\s*;\s*$/gmi;
var contents = options.data;
var dirname = path.dirname(options.file);
var imports = {};

@@ -175,5 +178,6 @@ var match;

// [1] single quotes
// [2] double quotes
// [1] single quotes filename
// [2] double quotes filename
var importFile = match[1] || match[2];
const fileExistCheck = analyseDirs(dirs, importFile);

@@ -185,22 +189,41 @@

}
}
for(let imp in imports) {
// replace @import with import file contents
if (sync) {
for(let filename in imports) {
let filepath = imports[filename];
let file = vfile.readSync(filepath);
// replace @import with import file contents
let file = vfile.readSync(imports[imp]);
let result = importReplacer({
data: file.contents.toString(),
file: file.path,
includePaths: dirs
});
let newFileContent = importReplacer({
data: file.contents.toString(),
file: file.path,
includePaths: dirs
}, true);
contents = contents.replace(new RegExp(imp, 'g'), function () {
// http://stackoverflow.com/a/28103073
return result
});
contents = contents.replace(new RegExp(filename, 'g'), newFileContent);
}
return contents;
} else {
let prevPromise = Promise.resolve(contents);
for(let filename in imports) {
let filepath = imports[filename];
prevPromise = prevPromise.then(contents => {
return vfile.read(filepath).then(file => {
return importReplacer({
data: file.contents.toString(),
file: file.path,
includePaths: dirs
});
}).then(newFileContent => {
return contents.replace(new RegExp(filename, 'g'), newFileContent);
});
});
}
return prevPromise;
}
return contents;
}

@@ -212,39 +235,12 @@

* @param {Object} opts
* @param {cb} function
* @param {Function} cb
* @api public
*/
module.exports.render = function(opts, cb, errorCb) {
var options = getOptions(opts, cb);
// TODO: add async render functionality
importReplacer(options).then(cb, errorCb);
};
// module.exports.render = function(opts, callback) {
// var options = getOptions(opts, callback);
// // options.error and options.success are for libsass binding
// options.error = function(err) {
// var payload = assign(new Error(), JSON.parse(err));
// if (callback) {
// options.context.callback.call(options.context, payload, null);
// }
// };
// options.success = function() {
// var result = options.result;
// var stats = endStats(result.stats);
// var payload = {
// css: result.css,
// map: result.map,
// stats: stats
// };
// if (callback) {
// options.context.callback.call(options.context, null, payload);
// }
// };
// // todo
// importReplacer(options, callback);
// };
/**

@@ -260,7 +256,5 @@ * Render sync

// var importer = options.importer;
// todo
// var status = importReplacer(options);
return importReplacer(options);
return importReplacer(options, true);

@@ -275,2 +269,2 @@ // var result = options.result;

// throw assign(new Error(), JSON.parse(result.error));
};
};
{
"name": "gulp-shopify-sass",
"version": "0.4.0",
"version": "0.4.1",
"description": "Concatenate Sass files defined by the @import order",

@@ -5,0 +5,0 @@ "main": "./index.js",

@@ -207,2 +207,20 @@ var assert = require('stream-assert');

it('synchronize render test', function(done) {
var sassFile = createVinyl('import.liquid.scss');
var stream = gulpShopifySass.sync();
stream.on('data', function(catScssFile) {
should.exist(catScssFile);
should.exist(catScssFile.path);
should.exist(catScssFile.relative);
should.exist(catScssFile.contents);
should.equal(path.basename(catScssFile.path), 'import.liquid.cat.scss.liquid');
String(catScssFile.contents).should.equal(
fs.readFileSync(path.join(__dirname, 'fixtures', 'expected', 'import.liquid.cat.scss.liquid'), 'utf8')
);
done();
});
stream.write(sassFile);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc