Last change
on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | var path = require('path');
|
---|
2 | var test = require('tape');
|
---|
3 | var resolve = require('../');
|
---|
4 |
|
---|
5 | test('filter', function (t) {
|
---|
6 | t.plan(4);
|
---|
7 | var dir = path.join(__dirname, 'resolver');
|
---|
8 | var packageFilterArgs;
|
---|
9 | resolve('./baz', {
|
---|
10 | basedir: dir,
|
---|
11 | packageFilter: function (pkg, pkgfile) {
|
---|
12 | pkg.main = 'doom'; // eslint-disable-line no-param-reassign
|
---|
13 | packageFilterArgs = [pkg, pkgfile];
|
---|
14 | return pkg;
|
---|
15 | }
|
---|
16 | }, function (err, res, pkg) {
|
---|
17 | if (err) t.fail(err);
|
---|
18 |
|
---|
19 | t.equal(res, path.join(dir, 'baz/doom.js'), 'changing the package "main" works');
|
---|
20 |
|
---|
21 | var packageData = packageFilterArgs[0];
|
---|
22 | t.equal(pkg, packageData, 'first packageFilter argument is "pkg"');
|
---|
23 | t.equal(packageData.main, 'doom', 'package "main" was altered');
|
---|
24 |
|
---|
25 | var packageFile = packageFilterArgs[1];
|
---|
26 | t.equal(
|
---|
27 | packageFile,
|
---|
28 | path.join(dir, 'baz/package.json'),
|
---|
29 | 'second packageFilter argument is "pkgfile"'
|
---|
30 | );
|
---|
31 |
|
---|
32 | t.end();
|
---|
33 | });
|
---|
34 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.