Browse Source

Merge pull request #130 from rollup/istanbul

Add code coverage with Istanbul and Codecov
better-aggressive
Rich Harris 10 years ago
parent
commit
a2974244cb
  1. 1
      .gitignore
  2. 3
      .travis.yml
  3. 3
      gobblefile.js
  4. 9
      package.json
  5. 6
      src/Module.js
  6. 4
      src/rollup.js
  7. 6
      src/utils/sourceMappingURL.js

1
.gitignore

@ -3,3 +3,4 @@ node_modules
.gobble*
dist
_actual
coverage

3
.travis.yml

@ -1,9 +1,10 @@
sudo: false
language: node_js
node_js:
- "0.10"
- "0.12"
- "iojs"
env:
global:
- BUILD_TIMEOUT=10000
install: npm install
script: npm run ci

3
gobblefile.js

@ -8,7 +8,8 @@ var node = src
entry: 'rollup.js',
dest: 'rollup.js',
format: 'cjs',
external: [ 'sander', 'acorn' ]
external: [ 'sander', 'acorn' ],
sourceMap: true
})
.transform( 'babel' );

9
package.json

@ -8,8 +8,12 @@
"rollup": "./bin/rollup"
},
"scripts": {
"test": "mocha",
"pretest": "npm run build",
"test": "mocha",
"pretest-coverage": "npm run build",
"test-coverage": "istanbul cover --report json node_modules/.bin/_mocha -- -u exports -R spec test/test.js",
"posttest-coverage": "remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped.json -b dist",
"ci": "npm run test-coverage && codecov < coverage/coverage-remapped.json",
"build": "gobble build -f dist",
"prepublish": "npm test",
"lint": "eslint src"
@ -37,6 +41,7 @@
"devDependencies": {
"babel": "^5.8.21",
"babel-core": "^5.5.8",
"codecov.io": "^0.1.6",
"console-group": "^0.1.2",
"eslint": "^1.1.0",
"gobble": "^0.10.1",
@ -46,7 +51,9 @@
"gobble-esperanto-bundle": "^0.2.0",
"gobble-rollup": "^0.8.0",
"gobble-rollup-babel": "^0.1.0",
"istanbul": "^0.3.20",
"mocha": "^2.2.4",
"remap-istanbul": "^0.2.0",
"source-map": "^0.4.4"
},
"dependencies": {

6
src/Module.js

@ -6,6 +6,7 @@ import walk from './ast/walk';
import { blank, keys } from './utils/object';
import getLocation from './utils/getLocation';
import makeLegalIdentifier from './utils/makeLegalIdentifier';
import SOURCEMAPPING_URL from './utils/sourceMappingURL';
function isEmptyExportedVarDeclaration ( node, exports, toExport ) {
if ( node.type !== 'VariableDeclaration' || node.declarations[0].init ) return false;
@ -18,9 +19,10 @@ function isEmptyExportedVarDeclaration ( node, exports, toExport ) {
}
function removeSourceMappingURLComments ( source, magicString ) {
const pattern = /\/\/#\s+sourceMappingURL=.+\n?/g;
const SOURCEMAPPING_URL_PATTERN = new RegExp( `\\/\\/#\\s+${SOURCEMAPPING_URL}=.+\\n?`, 'g' );
let match;
while ( match = pattern.exec( source ) ) {
while ( match = SOURCEMAPPING_URL_PATTERN.exec( source ) ) {
magicString.remove( match.index, match.index + match[0].length );
}
}

4
src/rollup.js

@ -1,11 +1,9 @@
import { basename } from './utils/path';
import { writeFile } from 'sander';
import { keys } from './utils/object';
import SOURCEMAPPING_URL from './utils/sourceMappingURL';
import Bundle from './Bundle';
let SOURCEMAPPING_URL = 'sourceMa';
SOURCEMAPPING_URL += 'ppingURL';
export function rollup ( options ) {
if ( !options || !options.entry ) {
throw new Error( 'You must supply options.entry to rollup' );

6
src/utils/sourceMappingURL.js

@ -0,0 +1,6 @@
// this looks ridiculous, but it prevents sourcemap tooling from mistaking
// this for an actual sourceMappingURL
let SOURCEMAPPING_URL = 'sourceMa';
SOURCEMAPPING_URL += 'ppingURL';
export default SOURCEMAPPING_URL;
Loading…
Cancel
Save