fis-postprocessor-jswrapper
Advanced tools
Comparing version 0.0.11 to 0.0.12
17
index.js
@@ -7,6 +7,6 @@ /* | ||
'use strict'; | ||
module.exports = function(content, file, conf){ | ||
module.exports = function (content, file, conf) { | ||
var options = file.jswrapper; | ||
if(file.isMod || conf.wrapAll || options) { | ||
if (file.isMod || conf.wrapAll || options) { | ||
@@ -17,12 +17,13 @@ var template = getConfig('template', options, conf); | ||
// wrap | ||
if(template){ | ||
if (template) { | ||
content = String(template) | ||
.split('${content}').join(content) | ||
.split('${id}').join(file.getId()); | ||
} else if(type === 'amd') { | ||
if(!/(^|[^.])\bdefine\s*\(/.test(content)){ | ||
content = 'define(\'' + file.getId() + '\', function(require, exports, module){ ' + content + ' \r\n});'; | ||
} else if (type === 'amd') { | ||
if (!/^\s*define\s*\(/.test(content)) { | ||
content = 'define(\'' + file.getId() + '\', function(require, exports, module){ ' + content + | ||
' \r\n});'; | ||
} | ||
} else { | ||
if(!/^\s*(?:[!(]\s*|void\s+)function\(/.test(content)){ | ||
if (!/^\s*(?:[!(]\s*|void\s+)function\(/.test(content)) { | ||
content = '!function(){try{ ' + content + ' \r\n}catch(e){}}();'; | ||
@@ -37,2 +38,2 @@ } | ||
return local && typeof local[key] !== 'undefined' ? local[key] : global[key]; | ||
} | ||
} |
{ | ||
"name" : "fis-postprocessor-jswrapper", | ||
"description" : "A postprocessor plugin for fis to wrap javascript with closure or amd define.", | ||
"version" : "0.0.11", | ||
"author" : "FIS Team <fis@baidu.com>", | ||
"homepage" : "http://fis.baidu.com/", | ||
"keywords": [ "fis" ], | ||
"main" : "index.js", | ||
"name": "fis-postprocessor-jswrapper", | ||
"description": "A postprocessor plugin for fis to wrap javascript with closure or amd define.", | ||
"version": "0.0.12", | ||
"author": "FIS Team <fis@baidu.com>", | ||
"homepage": "http://fis.baidu.com/", | ||
"keywords": ["fis"], | ||
"main": "index.js", | ||
"repository": { | ||
@@ -13,8 +13,8 @@ "type": "git", | ||
}, | ||
"engines" : { | ||
"node" : ">= 0.8.0" | ||
"engines": { | ||
"node": ">= 0.8.0" | ||
}, | ||
"scripts" : { | ||
"test" : "mocha test/ut --recursive" | ||
"scripts": { | ||
"test": "mocha test/ut --recursive" | ||
} | ||
} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
3865
0