Skip to content

Commit dc7c550

Browse files
committed
fix: get missed location and main
1 parent 951820f commit dc7c550

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

spec/package.spec.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,35 @@ test('package rejects invalid options', t => {
1010
test('package takes simple package name', t => {
1111
const p = new Package('a');
1212
t.equal(p.name, 'a');
13+
t.equal(p.location, undefined);
14+
t.equal(p.main, undefined);
1315
t.equal(p.shim, undefined);
1416
t.notOk(p.lazyMain);
1517
t.end();
1618
});
1719

1820
test('package takes options', t => {
19-
const p = new Package({name: 'a', lazyMain: true, version: '2.1.0'});
21+
const p = new Package({name: 'a', location: 'f/a', lazyMain: true, version: '2.1.0'});
2022
t.equal(p.name, 'a');
23+
t.equal(p.location, 'f/a');
24+
t.equal(p.main, undefined);
2125
t.equal(p.version, '2.1.0');
2226
t.equal(p.shim, undefined);
2327
t.ok(p.lazyMain);
2428
t.end();
2529
});
2630

31+
test('package takes options case2', t => {
32+
const p = new Package({name: 'a', location: 'f/a', main: './aa.js'});
33+
t.equal(p.name, 'a');
34+
t.equal(p.location, 'f/a');
35+
t.equal(p.main, './aa.js');
36+
t.equal(p.version, undefined);
37+
t.equal(p.shim, undefined);
38+
t.notOk(p.lazyMain);
39+
t.end();
40+
});
41+
2742
test('package takes shim options', t => {
2843
const p = new Package({name: 'a', deps: ['b', 'c'], exports: 'A', wrapShim: true});
2944
t.equal(p.name, 'a');

src/package.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export default class Package {
1515
throw new Error('not a valid package options, use "packageName" or {name: "packageName", ...}');
1616
}
1717

18+
this.location = (typeof opts.location === 'string') ? opts.location : undefined;
19+
this.main = (typeof opts.main === 'string') ? opts.main : undefined;
1820
this.version = (typeof opts.version === 'string') ? opts.version : undefined;
1921
this.lazyMain = !!opts.lazyMain;
2022

0 commit comments

Comments
 (0)