fly-uglify
Advanced tools
Comparing version 1.0.0 to 2.0.0
26
index.js
@@ -1,10 +0,20 @@ | ||
const assign = require("object-assign") | ||
const minify = require("uglify-js").minify | ||
'use strict'; | ||
const extn = require('path').extname; | ||
const minify = require('uglify-js').minify; | ||
module.exports = function () { | ||
this.filter("uglify", (data, options) => { | ||
return assign({ ext: ".js" }, minify(data.toString(), assign({ | ||
fromString: true | ||
}, options))) | ||
}) | ||
} | ||
this.plugin('uglify', {}, function * (file, opts) { | ||
opts = Object.assign({}, opts, {fromString: 1}); | ||
const ext = extn(file.base); | ||
const rgx = new RegExp(ext, 'i'); | ||
// replace extension with `.js` | ||
file.base = file.base.replace(rgx, '.js'); | ||
const out = minify(file.data.toString(), opts); | ||
// write output | ||
file.data = new Buffer(out.code); | ||
}); | ||
}; |
{ | ||
"name": "fly-uglify", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Uglify plugin for Fly", | ||
@@ -9,29 +9,28 @@ "license": "MIT", | ||
"scripts": { | ||
"lint": "eslint *.js", | ||
"setup": "npm i && npm test", | ||
"spec": "npm run test | tspec", | ||
"test": "npm run lint && npm run test-harmony", | ||
"build": "echo No build task specified.", | ||
"deploy": "npm run test && git push origin master && npm publish", | ||
"test-harmony": "node --harmony --harmony_arrow_functions ./node_modules/tape/bin/tape test/*.js" | ||
"test": "xo && tape test/*.js | tap-spec" | ||
}, | ||
"author": "Jorge Bucaran", | ||
"keywords": [ | ||
"fly", | ||
"fly-plugin", | ||
"uglify" | ||
], | ||
"dependencies": { | ||
"object-assign": "^3.0.0", | ||
"uglify-js": "^2.4.23" | ||
"uglify-js": "^2.7.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^0.21.2", | ||
"fly": "beta", | ||
"tap-spec": "^4.0.2", | ||
"tape": "^4.0.0" | ||
"tape": "^4.0.0", | ||
"xo": "*" | ||
}, | ||
"engines": { | ||
"iojs": ">= 1.0.0", | ||
"node": ">= 0.11.0" | ||
"node": ">= 4.6.0" | ||
}, | ||
"keywords": [ | ||
"fly", | ||
"fly-plugin", | ||
"uglify" | ||
] | ||
"xo": { | ||
"rules": { | ||
"require-yield": 1, | ||
"curly": 1 | ||
} | ||
} | ||
} |
@@ -1,14 +0,39 @@ | ||
const test = require("tape").test | ||
const uglify = require("../") | ||
'use strict'; | ||
test("fly-uglify", (t) => { | ||
t.plan(3) | ||
uglify.call({ | ||
filter: function (name, transform) { | ||
const res = transform("/* yay */") | ||
t.equal(name, "uglify", "add uglify filter") | ||
t.ok(/^\s*$/.test(res.code), "uglify transform") | ||
t.equal(res.ext, ".js", "extension is .js") | ||
} | ||
}) | ||
}) | ||
const join = require('path').join; | ||
const test = require('tape').test; | ||
const Fly = require('fly'); | ||
const dir = join(__dirname, 'fixtures'); | ||
const tmp = join(__dirname, 'tmp'); | ||
test('fly-uglify', t => { | ||
t.plan(4); | ||
const fly = new Fly({ | ||
plugins: [{ | ||
func: require('../') | ||
}], | ||
tasks: { | ||
a: function * () { | ||
const src = `${dir}/**/*.js`; | ||
t.ok('uglify' in fly, 'attach `uglify()` plugin to fly'); | ||
yield this.source(src).uglify().target(tmp); | ||
const str1 = yield this.$.read(`${tmp}/a.js`, 'utf8'); | ||
t.equal(str1, `console.log("this is a");`, 'apply `uglify-js` to content'); | ||
const arr1 = yield this.$.expand(`${tmp}/**/*.js`); | ||
t.equal(arr1.length, 2, 'keep all files'); | ||
/* eslint camelcase:0 */ | ||
yield this.source(src).uglify({compress: {drop_console: 1}}).target(tmp); | ||
const str2 = yield this.$.read(`${tmp}/a.js`, 'utf8'); | ||
t.equal(str2, '', 'accept custom config (`compress` options)'); | ||
yield this.clear(tmp); | ||
} | ||
} | ||
}); | ||
fly.start('a'); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
10
52
4563
4
44
- Removedobject-assign@^3.0.0
- Removedobject-assign@3.0.0(transitive)
Updateduglify-js@^2.7.0