Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

importless

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

importless - npm Package Compare versions

Comparing version
0.1.1
to
0.1.2
+1
-1
Gruntfile.js

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

// Default task.
grunt.registerTask('default', 'lint test');
grunt.registerTask('default', 'test');
};

@@ -15,3 +15,3 @@ // Generated by CoffeeScript 1.3.1

var fs, glob, less, path,
var fs, glob, ignored, less, path,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

@@ -27,2 +27,18 @@

ignored = [];
exports.setIgnored = function(paths) {
if (paths == null) {
paths = [];
}
if (typeof paths === 'string') {
paths = [paths];
}
return ignored = paths;
};
exports.getIgnored = function() {
return ignored;
};
exports.detectDependencies = function(directories) {

@@ -41,3 +57,4 @@ var dir, files, _i, _len;

files = this.cssToLess(files);
return files = this.stripImported(files, this.getImported(files));
files = this.stripImported(files, this.getImported(files));
return files = this.stripIgnored(files, this.getIgnored());
};

@@ -102,8 +119,20 @@

return false;
} else {
return true;
}
return true;
});
};
exports.stripIgnored = function(files, ignored) {
return files.filter(function(filepath) {
var ignoredPath, _i, _len;
for (_i = 0, _len = ignored.length; _i < _len; _i++) {
ignoredPath = ignored[_i];
if (glob.minimatch(filepath, ignoredPath)) {
return false;
}
}
return true;
});
};
}).call(this);
{
"name": "importless",
"description": "Find stylesheet files (css and less) and strip away the @imported ones",
"version": "0.1.1",
"version": "0.1.2",
"homepage": "https://github.com/excellenteasy/importless",

@@ -6,0 +6,0 @@ "author": {

@@ -12,6 +12,15 @@ ###

glob = require 'glob-whatev'
fs = require 'fs'
fs = require 'fs'
less = require 'less'
path = require 'path'
# ignore option to ignore certain file paths
# you can provide any minimatch pattern
# an array of directories that should be ignored
ignored = []
exports.setIgnored = (paths=[]) ->
if typeof paths is 'string' then paths = [paths]
ignored = paths
exports.getIgnored = -> ignored
# returns an array of filepaths of less/css files

@@ -25,8 +34,9 @@ # in current directory (or otherwise specified)

files = @stripImported files, @getImported(files)
files = @stripIgnored files, @getIgnored()
# return both less and css files from directory
exports.findAll = (directory) ->
# remove trailing slash
if /\/$/.test(directory) then directory = directory.replace /\/$/, ''
return glob.glob("#{directory}/**/*.{less,css}")
# remove trailing slash
if /\/$/.test(directory) then directory = directory.replace /\/$/, ''
return glob.glob("#{directory}/**/*.{less,css}")

@@ -67,2 +77,9 @@ # returns array of filespaths where .css files are converted to .less

# check if filepath is in imported
if filepath in imported then false else true
if filepath in imported then return false
true
exports.stripIgnored = (files, ignored) ->
files.filter (filepath) ->
for ignoredPath in ignored
if glob.minimatch(filepath, ignoredPath) then return false
true

@@ -76,2 +76,12 @@ "use strict"

exports['setIgnored'] =
'ignore `ignore` directory when set': (test) ->
test.expect 1
importless.setIgnored '**/test2.*'
files = importless.findAll 'test/files'
test.deepEqual importless.stripIgnored(files, importless.getIgnored()), ['test/files/imported.less', 'test/files/test.less']
importless.setIgnored []
test.done()
exports['detectDependencies'] =

@@ -78,0 +88,0 @@ setUp: (next) ->