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

grunt-usemin

Package Overview
Dependencies
Maintainers
4
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-usemin - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

13

lib/cssprocessor.js

@@ -7,6 +7,5 @@ 'use strict';

// It is given:
// - An object representing the file, with the following keys:
// name: name of the file (optional)
// dir: directory location of the file to examine
// content: the content of the file to look at
// - A base directory, which is the directory under which to look at references files
// - A destination directory, which is the directory under which will be generated the files
// - A file content to be processed
// - a file replacement locator

@@ -16,5 +15,5 @@ // - a destination directory (optional)

//
var CSSProcessor = module.exports = function (file, revvedfinder, logcb) {
this.content = file.content;
this.filepath = file.dir;
var CSSProcessor = module.exports = function (src, dest, content, revvedfinder, logcb) {
this.content = content;
this.filepath = src;
this.linefeed = /\r\n/g.test(this.content) ? '\r\n' : '\n';

@@ -21,0 +20,0 @@ this.revvedfinder = revvedfinder;

@@ -36,3 +36,3 @@ 'use strict';

//
var getBlocks = function (dir, content) {
var getBlocks = function (dest, dir, content) {
// start build pattern --> <!-- build:[target] output -->

@@ -64,3 +64,3 @@ var regbuild = /<!--\s*build:(\w+)\s*([^\s]+)\s*-->/;

type: build[1],
dest: path.join(dir, build[2]),
dest: path.join(dest, build[2]),
startFromRoot: startFromRoot,

@@ -110,17 +110,17 @@ indent: indent,

// It is given:
// - An object representing the file, with the following keys:
// name: name of the file (optional)
// dir: directory location of the file to examine
// content: the content of the file to look at
// - A base directory, which is the directory under which to look at references files
// - A destination directory, which is the directory under which will be generated the files
// - A file content to be processed
// - a file replacement locator
// - an optional log callback that will be called as soon as there's something to log
//
var HTMLProcessor = module.exports = function (file, revvedfinder, logcb) {
var HTMLProcessor = module.exports = function (src, dest, content, revvedfinder, logcb) {
// FIXME: Check consistency of the file object
this.file = file;
this.relativePath = path.relative(process.cwd(), file.dir);
this.content = file.content;
this.src = src;
this.dest = dest || src;
this.content = content;
this.relativeSrc = path.relative(process.cwd(), src);
this.revvedfinder = revvedfinder;
this.linefeed = /\r\n/g.test(this.content) ? '\r\n' : '\n';
this.blocks = getBlocks(this.relativePath, this.content);
this.blocks = getBlocks(this.dest, this.relativeSrc, this.content);
this.logcb = logcb || function () {};

@@ -145,3 +145,3 @@ };

// file
var dest = path.relative(this.relativePath, block.dest);
var dest = path.relative(this.relativeSrc, block.dest);

@@ -158,5 +158,5 @@ if (block.startFromRoot) {

} else if (block.requirejs !== undefined) {
var dataMain = path.relative(this.relativePath, block.requirejs.dest);
var dataMain = path.relative(this.relativeSrc, block.requirejs.dest);
dataMain = dataMain.replace(backslash, '/');
var requireSrc = path.relative(this.relativePath, block.requirejs.src);
var requireSrc = path.relative(this.relativeSrc, block.requirejs.src);
requireSrc = requireSrc.replace(backslash, '/');

@@ -236,3 +236,3 @@ if (block.startFromRoot) {

var srcfile = filter(src);
var file = self.revvedfinder.find(srcfile, self.file.dir);
var file = self.revvedfinder.find(srcfile, self.src);
var res = match.replace(src, file);

@@ -239,0 +239,0 @@

{
"name": "grunt-usemin",
"version": "0.1.5",
"version": "0.1.6",
"description": "Grunt task replaces references to non-optimized scripts or stylesheets into a set of HTML files (or any templates/views).",

@@ -5,0 +5,0 @@ "keywords": [

@@ -85,8 +85,2 @@ # grunt-usemin [![Build Status](https://secure.travis-ci.org/yeoman/grunt-usemin.png?branch=master)](http://travis-ci.org/yeoman/grunt-usemin)

### dirs
Type: 'array of strings'
Default: nil
Used to limit the directories that will be looked for revved files when replacing reference. By default all subdirectories are looked at.
### dest

@@ -111,6 +105,26 @@ Type: 'string'

```
### dirs
Type: 'array of strings'
Default: nil
Used to limit the directories that will be looked for revved files when replacing reference. By default all subdirectories are looked at.
### Basedir
Type: 'string'
Default: nil
Change the basedir that represent the location of the transformed file. For example, let's imagine you have someting like:
```
|
+--- styles
\ main.css
+--- views
\ index.html
```
By default, if the file to be transformed is `index.html`, the images, scripts, ... referenced by this file will be considered are being in the `views` directory, whereas they must be linked to the `styles` directory.
## License
[BSD license](http://opensource.org/licenses/bsd-license.php) and copyright Google

@@ -99,3 +99,3 @@ 'use strict';

// ext-specific directives handling and replacement of blocks
var proc = new processors[name]({dir: filedir, content: content}, revvedfinder, function (msg) {
var proc = new processors[name](filedir, '', content, revvedfinder, function (msg) {
grunt.log.writeln(msg);

@@ -137,3 +137,3 @@ });

var revvedfinder = new RevvedFinder(function (p) { return grunt.file.expand({filter: 'isFile'},p); } );
var proc = new HTMLProcessor({dir: path.dirname(file.path), content: file.body}, revvedfinder, function (msg) {
var proc = new HTMLProcessor(path.dirname(file.path), dest, file.body, revvedfinder, function (msg) {
grunt.log.writeln(msg);

@@ -148,11 +148,4 @@ });

var outputDestination = function (obj, dst, input) {
if (dest) {
dst = path.join(dest, dst);
}
obj[dst] = input;
};
// update concat config for this block
outputDestination(concat, block.dest, block.src);
concat[block.dest] = block.src;
grunt.config('concat', concat);

@@ -200,3 +193,3 @@

// using concat before ... Option ?
outputDestination(uglify, block.dest, block.dest);
uglify[block.dest] = block.dest;
grunt.config(uglifyName, uglify);

@@ -207,3 +200,3 @@ }

if (block.type === 'css') {
outputDestination(cssmin, block.dest, block.src);
cssmin[block.dest] = block.dest;
grunt.config(cssminName, cssmin);

@@ -210,0 +203,0 @@ }

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