Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
岑安 committed Mar 2, 2015
1 parent b64f58d commit d027d9e
Show file tree
Hide file tree
Showing 41 changed files with 126 additions and 319 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_js:
- "0.11"
- "0.10"
language: node_js
script: "npm run-script test-travis"
after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# PackageTool

v0.1.2
v0.1.3
A package tool for Mtb-PackageApp auto-checking & auto-packing

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Downloads][downloads-image]][downloads-url]

## Usage

```shell
Expand Down
309 changes: 0 additions & 309 deletions index.js

This file was deleted.

14 changes: 13 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ Pack.prototype = {
*/
parseHtml: function (htmlstr, filePath) {
var me = this;
this.zipdir = mkZipDirs(filePath);

if (!this.zipdir) {
this.zipdir = mkZipDirs(filePath);
}

var $ = cheerio.load(htmlstr, {decodeEntities: false, normalizeWhitespace: false});
$('link,script,img').each(function (i, el) {
Expand Down Expand Up @@ -100,6 +103,11 @@ Pack.prototype = {
},
parseUriInCss: function (cssstr, filePath, uri) {
var me = this;

if (!this.zipdir) {
this.zipdir = mkZipDirs(filePath);
}

if (uri) {
// 如果是在线down下来的css, 里面内容即使是相对路径的引用的资源,也要当作在线的处理

Expand All @@ -124,6 +132,10 @@ Pack.prototype = {
var me = this;
this._need ++;

if (!this.zipdir) {
this.zipdir = mkZipDirs('');
}

function _dosave (dest, cb) {
fs.ensureFileSync(dest);

Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "packageapp",
"version": "0.1.2",
"version": "0.1.3",
"description": "A tool for mtb-PackageApp auto-checking & auto-packing",
"main": "lib/core.js",
"bin": {
"pack": "bin/pack.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha",
"test-travis": "node node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --reporter dot"
},
"repository": {
"type": "git",
Expand All @@ -25,6 +26,10 @@
"chalk": "^1.0.0",
"request": "^2.53.0"
},
"devDependencies": {
"istanbul": "^0.3.6",
"mocha": "^2.1.0"
},
"author": "cenan.chr",
"license": "MIT",
"bugs": {
Expand Down
Binary file added test/assets/app.zip
Binary file not shown.
File renamed without changes.
File renamed without changes.

0 comments on commit d027d9e

Please sign in to comment.