-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (24 loc) · 751 Bytes
/
index.js
File metadata and controls
25 lines (24 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
* fis
* http://fis.baidu.com/
*/
'use strict';
module.exports = function(content, file, conf){
if(file.isMod || conf.wrapAll){
//wrap
if(conf.template){
content = String(conf.template)
.split('${content}').join(content)
.split('${id}').join(file.getId());
} else if(conf.type === 'amd') {
if(!/^\s*define\s*\(/.test(content)){
content = 'define(function(require, exports, module){\n\n' + content + '\n\n});';
}
} else {
if(!/^\s*(?:[!(]\s*|void\s+)function\(/.test(content)){
content = '!function(){try{\n\n' + content + '\n\n}catch(e){}}();';
}
}
}
return content;
};