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

grunt-combohtml

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-combohtml - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

8

package.json
{
"name": "grunt-combohtml",
"description": "The best Grunt plugin ever.",
"version": "0.1.1",
"version": "0.1.2",
"homepage": "",

@@ -39,6 +39,6 @@ "author": {

],
"readme": "",
"readme": "# grunt-flexcombo\n\n> [flex-combo](https://npmjs.org/package/flex-combo)插件的grunt版本.\n\n## Getting Started\n\n依赖 Grunt 版本`~0.4.1`\n\n安装\n\n```shell\nnpm install grunt-flexcombo --save-dev\n```\n\n安装后,在Gruntfile.js中载入任务\n\n```js\ngrunt.loadNpmTasks('grunt-flexcombo');\n```\n\n## \"flexcombo\" 任务配置\n\n### 步骤\n\n在`grunt.initConfig()`中添加flexcombo的配置:\n\n```js\ngrunt.initConfig({\n\tflexcombo:{\n\t\toptions: {\n\t\t\ttarget:'src',\n\t\t\turls:'/group/project',\n\t\t\tport:'80',\n\t\t\tservlet:'?',\n\t\t\tseparator:',',\n\t\t\tcharset:'utf8'\n\t\t},\n\t\tmain:{}\n\t}\n});\n```\n\n你的host指向开发机,访问http://host/group/projecct,浏览你的页面和assets文件\n\n将cdn配向开发机\n\t\n\t127.0.0.1 g.tbcdn.cn\n\n可以访问你的页面和asset文件\n\n\thttp://g.tbcdn.cn/group/project\n\n更多配置请参照[flex-combo](https://npmjs.org/package/flex-combo)。\n\n## 说明\n\n该服务添加了[jayli-server](https://npmjs.org/package/jayli-server),支持标准格式的 SSI include\n\n\t<!--#include path=\"asdf.html\" -->\n\n## 使用\n\n建议同[generator-clam](https://npmjs.org/package/generator-clam)一同使用,构建工具生成本地配置文件,形如:\n\n\n\tflexcombo:{\n\t\toptions: {\n\t\t\ttarget:'src',\n\t\t\turls:'/<%= pkg.group %>/<%= pkg.name %>',\n\t\t\tport:'<%= port %>',\n\t\t\tservlet:'?',\n\t\t\tseparator:',',\n\t\t\tcharset:'utf8'\n\t\t},\n\t\tmain:{}\n\t}\n\n执行任务\n\n\ttask.run(['flexcombo']);\n",
"readmeFilename": "README.md",
"_id": "grunt-flexcombo@0.1.8",
"_from": "grunt-flexcombo@",
"_id": "grunt-combohtml@0.1.1",
"_from": "grunt-combohtml@",
"dist": {

@@ -45,0 +45,0 @@ "shasum": "876e2218d24b85ff2c43365a7f42569528a40fed"

/*
* grunt-flexcombo
*

@@ -12,4 +11,2 @@ *

var http = require('http');
var flexCombo = require('flex-combo');
var jayli = require('jayli-server');
var ssi = require('./ssi').ssi,

@@ -39,3 +36,3 @@ ssiChunk = require('./ssi').ssiChunk,

this.files.forEach(function(v,k){
console.log(v);
console.log(v.dest);
var p = v.src[0];

@@ -52,3 +49,2 @@ var bf = read(p);

var chunk = ssiChunk(p,bf.toString('utf8'));
chunk = tidy(chunk);

@@ -58,8 +54,8 @@ var result = extract.parse(chunk);

// var js_content = concat(result.js,dest_js,v.orig.dest);
var css_content = concat(result.css,dest_css,v.orig.dest);
console.log(chunk);
console.log(css_content);
var js_content = concat(result.js,dest_js,v.orig.cwd);
var css_content = concat(result.css,dest_css,v.orig.cwd);
//console.log(extract.parse(chunk));
chunk = chunk.replace('@@script',path.basename(v.dest,path.extname(v.dest)) + '.js');
chunk = chunk.replace('@@style',path.basename(v.dest,path.extname(v.dest)) + '.css');
chunk = tidy(chunk);

@@ -66,0 +62,0 @@ if(!(chunk instanceof Buffer)){

@@ -21,3 +21,3 @@ // 'use strict';

var ap = path.resolve(pwd,dest,v);
console.log(ap);
// console.log(ap);
if(!fs.existsSync(ap)){

@@ -24,0 +24,0 @@ return;

@@ -24,13 +24,51 @@ // 'use strict';

function parse(content){
css(content);
content = CONTENT;
js(content);
content = CONTENT;
CONTENT = '';
content = css(content);
content = js(content);
return {
content:recall(content),
js:JS_Files,
css:CSS_Files
content:insertScript(recall(content)),
js:distinct(JS_Files),
css:distinct(CSS_Files)
};
}
function inArray (v, a){
var o = false;
for(var i=0,m=a.length; i<m; i++){
if(a[i] == v){
o = true;
break;
}
}
return o;
}
function distinct(A){
var that = this;
if(!(A instanceof Array) || A.length <=1 )return A;
A = A.reverse();
var a = [],b=[];
for(var i = 1;i<A.length;i++){
for(var j = 0;j<i;j++){
if(inArray(j,b))continue;
if(A[j] == A[i]){
b.push(j);
}
}
}
for(var i = 0;i<A.length;i++){
if(inArray(i,b))continue;
a.push(A[i]);
}
return a.reverse();
}
//
function insertScript(content){
return content.replace(/<\/head>/i,function(){
return '<!--comboJS--><script src="@@script"></script>\n'
+ '<!--comboCSS--><link href="@@style" rel="stylesheet" />\n'
+ '</head>';
});
}
function recall(content){

@@ -63,6 +101,8 @@

var firstInclude = o.file;
var r;
if(firstInclude){
JS_Files.push(firstInclude);
js(o.content);
r = js(o.content);
}
return r?r:content;
}

@@ -73,6 +113,8 @@

var firstInclude = o.file;
var r;
if(firstInclude){
CSS_Files.push(firstInclude);
css(o.content);
r = css(o.content);
}
return r?r:content;
}

@@ -100,23 +142,2 @@

/*
function parseFirstIncludes(p,content){
var pathname = path.dirname(p);
var includefile = hasIncludes(p);
var dpath = path.resolve(pathname,includefile);
var dcontent = getContent(dpath);
var rep = path.dirname(path.relative(pathname,includefile));
var xcontent = dcontent.replace(new RegExp(reg,'gi'),function(){
// console.log(arguments);
var args = arguments;
return "<!--#include " + args[3] + '="' + path.join(rep,args[4]) + '" -->';
});
CTS[dpath] = dcontent;
return content.replace(new RegExp(reg,'i'),xcontent);
}
*/
function hasIncludes(content,type){
}
// 得到的一定是utf8编码的buffer

@@ -123,0 +144,0 @@ function read(file){

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