📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP

gulp-shopify-sass

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-shopify-sass - npm Package Compare versions

Comparing version

to
0.1.3

@@ -13,2 +13,45 @@ 'use strict';

function addUnderscore(fileName) {
const index = fileName.lastIndexOf("/") + 1;
const start = fileName.substring(0, index);
const end = fileName.substring(index, fileName.length);
return start + '_' + end;
}
function checkFileExists(fileName) {
// if .scss is not specified at the end
const withExtension = fileName + '.scss';
// if the file name is missing the partial '_'
const withUnderscore = addUnderscore(fileName);
// if the file name is missing both the .scss extension and the partial '_'
const withUnderscoreAndExtension = withUnderscore + '.scss';
if(fileExists(fileName)) {
return fileName;
}
if(fileExists(withExtension)) {
return withExtension;
}
if(fileExists(withUnderscore)) {
return withUnderscore;
}
if(fileExists(withUnderscoreAndExtension)) {
return withUnderscoreAndExtension;
}
gutil.log('File to import: "' + fileName + '" not found.');
return false;
}
function importReplacer (file) {

@@ -21,2 +64,3 @@

var match;
while(match = rex.exec(fileContents)) {

@@ -28,9 +72,8 @@

// Skip files doesn't exist
if (!fileExists(importFile)) {
gutil.log('File to import: "' + importFile + '" not found.');
continue;
};
const fileExistCheck = checkFileExists(importFile);
imports[match[0]] = importFile;
// if file exists, replace it
if(fileExistCheck) {
imports[match[0]] = fileExistCheck;
}

@@ -41,3 +84,3 @@ }

// replace @import with import file contents
fileContents = fileContents.replace(imp, importReplacer(vfile.readSync(imports[imp])).contents.toString());
fileContents = fileContents.replace(new RegExp(imp, 'g'), importReplacer(vfile.readSync(imports[imp])).contents.toString());
}

@@ -68,2 +111,2 @@

});
}
}
{
"name": "gulp-shopify-sass",
"version": "0.1.2",
"version": "0.1.3",
"description": "Concatenate Sass files defined by the @import order",

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

@@ -9,3 +9,3 @@ # gulp-shopify-sass [![Build Status](https://travis-ci.org/theJian/gulp-shopify-sass.svg?branch=master)](https://travis-ci.org/theJian/gulp-shopify-sass)

install via npm:
npm install gulp-shopify-sass --save-dev

@@ -18,3 +18,3 @@

var gss = require('gulp-shopify-sass');
gulp.task('default', function() {

@@ -27,2 +27,2 @@ return gulp.src('./*.scss')

# License
MIT license
MIT license

@@ -17,2 +17,2 @@ var array = require('stream-array');

}));
}
}

@@ -42,3 +42,3 @@ var assert = require('stream-assert');

// });
it('replace import', function (done) {

@@ -53,3 +53,3 @@ gulp.src('./test/fixtures/b.scss')

it('replace import recursively', function (done) {
test('@import "b.scss";')
gulp.src('./test/fixtures/c.scss')
.pipe(gulpShopifySass())

@@ -61,4 +61,19 @@ .pipe(assert.length(1))

it('replace multiple import', function (done) {
gulp.src('./test/fixtures/d.scss')
.pipe(gulpShopifySass())
.pipe(assert.length(1))
.pipe(assert.first(function(f){f.contents.toString().should.equal('.class-name {}\n.class-name {}')}))
.pipe(assert.end(done));
});
it('replace multiple types of import', function (done) {
gulp.src('./test/fixtures/e.scss')
.pipe(gulpShopifySass())
.pipe(assert.length(1))
.pipe(assert.first(function(f){f.contents.toString().should.equal('.class-name {}\n.class-name {}\n.class-name {}\n.class-name {}')}))
.pipe(assert.end(done));
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet