UNPKG

1.04 kBJavaScriptView Raw
1'use strict';
2/*jshint asi: true */
3
4var test = require('tap').test
5 , path = require('path')
6 , fs = require('fs')
7 , browserify = require('browserify')
8 , convert = require('convert-source-map')
9 , mold = require('..')
10 , jsRoot = path.join(__dirname, '..', 'examples', 'project')
11
12test('mold sources', function (t) {
13 t.plan(1)
14
15 function map(src) {
16 return src + '// this is actually included in the sourcemap';
17 }
18
19 var bundle = '';
20 browserify()
21 .require(require.resolve('../examples/project/js/main.js'), { entry: true })
22 .bundle({ debug: true })
23 .on('error', function (err) { console.error(err); })
24
25 .pipe(mold.transformSourcesContent(map))
26 .on('data', function (data) {
27 bundle += data;
28 })
29 .on('end', function () {
30 var sm = convert.fromSource(bundle);
31 t.ok(~sm.getProperty('sourcesContent')[0].indexOf('// this is actually included in the sourcemap')
32 ,'molds all sources contents viat the map function')
33 });
34});