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

grunt-depsconcat

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-depsconcat - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

2

package.json
{
"name": "grunt-depsconcat",
"version": "0.1.0",
"version": "0.1.1",
"description": "Concatenate files in order based on dependencies",

@@ -5,0 +5,0 @@ "dependencies": {

@@ -1,9 +0,9 @@

var path, util, deptree;
module.exports = function(grunt) {
var path, util, deptree;
path = require('path');
util = require('util');
deptree = require('serialize-deptree');
path = require('path');
util = require('util');
deptree = require('serialize-deptree');
module.exports = function(grunt) {
grunt.registerMultiTask('depsconcat', 'Concatenate files, ordered by dependencies', function() {
grunt.registerMultiTask('depsconcat', 'Concatenate files, ordered by dependencies.', function() {
var options;

@@ -14,10 +14,10 @@

requireTemplate: null,
ext: null,
except: [],
ext: null
});
this.files.forEach(function(file) {
var regex, ext, files, tree;
this.files.forEach(function(f) {
var ext, files, tree, regex, serialized;
var filePath, i;
ext = options.ext || file.dest.match(/\.[a-z]+$/i)[0];
ext = options.ext || f.dest.match(/\.[a-z]+$/i)[0];
files = {};

@@ -27,17 +27,21 @@ tree = {};

if (!options.requireTemplate) {
if (ext === '.css') {
if (ext === '.css')
regex = '@import\\s+url\\(["\']?([^"\'()]+)["\']?\\);?[\\n\\r]*';
} else {
else {
ext = '.js';
regex = '\\/\\/@require\\s+([^\\n\\r]+)[\\n\\r]*';
}
} else {
} else
regex = options.requireTemplate;
}
regex = new RegExp(regex, 'gi');
file.src.filter(function(filePath) {
filePath = path.normalize(filePath);
f.src.filter(function(filePath) {
if (!grunt.file.exists(filePath)) {
grunt.log.warn('Source file ' + filepath + ' not found.');
return false;
}
return !grunt.file.isDir(filePath);
}).map(function(filePath) {
files[path.basename(filePath, ext)] = filePath;

@@ -47,26 +51,26 @@ tree[filePath] = [];

file.src.filter(function(filePath) {
var matches, depfilePath;
for (filePath in tree) {
var matches, name;
matches = grunt.file.read(filePath).match(regex) || [];
for (var i = 0; i < matches.length; i++) {
for (i = 0; i < matches.length; i++) {
regex.lastIndex = 0;
depfilePath = regex.exec(matches[i])[1];
name = regex.exec(matches[i])[1];
if (!(/\.\w+$/).test(depfilePath)) {
tree[path.normalize(filePath)].push(files[depfilePath]);
}
if (files[name])
tree[filePath].push(files[name]);
else
grunt.log.warn('Dependency ' + name + ' of ' + filePath + ' not found.');
}
});
}
var serialized = deptree.serialize(tree).map(function(filePath) {
serialized = deptree.serialize(tree).map(function(filePath) {
return grunt.file.read(filePath);
});
grunt.file.write(file.dest, serialized.join(grunt.util.linefeed));
grunt.log.writeln('Dest File "' + file.dest + '" created.');
grunt.file.write(f.dest, serialized.join(grunt.util.linefeed));
grunt.log.writeln('File ' + f.dest + ' created.');
});
});
};
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