Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-less-precompiler

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-less-precompiler - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

0

gulpfile.js

@@ -0,0 +0,0 @@ /* global require */

@@ -0,0 +0,0 @@ /* global require, module */

5

package.json
{
"name": "gulp-less-precompiler",
"version": "1.1.0",
"version": "1.1.1",
"description": "A gulp plugin that replaces imports with the imported file content.",

@@ -26,3 +26,4 @@ "main": "index.js",

"through2": "^2.0.0",
"vinyl": "^1.1.0"
"vinyl": "^1.1.0",
"vinyl-sourcemaps-apply": "^0.2.0"
},

@@ -29,0 +30,0 @@ "devDependencies": {

@@ -11,2 +11,3 @@ /* global require */

var File = require('vinyl');
var sourcemaps = require('vinyl-sourcemaps-apply');

@@ -20,5 +21,6 @@ var REGEX_IMPORT = new RegExp('@import [\'"](.+?)[\'"];');

* @param {Object} context
* @param {Boolean} debug Whether to display debug messages during work.
* @returns {Promise<Buffer>}
*/
function scanFile(file, promise, context) {
function scanFile(file, promise, context, debug) {
return new Promise(function(resolve, reject) {

@@ -48,4 +50,9 @@

if (!matches) {
gutil.log('=> ' + line);
if (debug) {
gutil.log('=> ' + line);
}
return builder.appendLine(line);
}

@@ -62,3 +69,3 @@

return scanFile(targetFile, promise, context);
return scanFile(targetFile, promise, context, debug);

@@ -82,7 +89,8 @@ });

* @param {File} file
* @param {Boolean} debug Whether to display debug messages during work.
* @returns {Promise<Buffer>}
**/
function startScan(file) {
function startScan(file, debug) {
gutil.log('Starting style precompilation with ' + file.path);
return scanFile(file, Promise.resolve(new StringBuilder()), []);
return scanFile(file, Promise.resolve(new StringBuilder()), [], debug);
}

@@ -92,7 +100,23 @@

* Creates a new precompiler for use in a gulp workflow.
* @param {Object} [options] Never actually used.
* @param {Object} [options] The plugin options.
* @param {Boolean} [options.debug] Whether to log debug messages.
*/
module.exports = function lessPrecompiler(options) {
var config = {
debug: options
&& options.debug,
sourceMaps: options
? options.sourceMaps !== false
: true,
push: options
&& options.push
};
return through2.obj(function(file, encoding, done) {
var self = this;

@@ -103,3 +127,3 @@ if (file.isNull()) {

startScan(file).then(function(builder) {
startScan(file, config.debug).then(function(builder) {

@@ -114,2 +138,11 @@ if (file.isBuffer()) {

file.contents = new Buffer(result);
if (config.sourceMaps && file.sourceMap) {
sourcemaps(file, result.map);
}
if (config.push) {
self.push(file);
}
done(null, file);

@@ -122,5 +155,23 @@

if (file.isStream()) {
file.contents = new Stream();
return builder.writeStream(file.contents, done);
return builder.writeStream(file.contents, function(error, result) {
if (error) {
return done(error);
}
if (config.sourceMaps && file.sourceMap) {
sourcemaps(file, result.map);
}
if (config.push) {
self.push(file);
}
done(null, file);
});
}

@@ -127,0 +178,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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