Skip to content

Commit 2004622

Browse files
authored
fix(build): fix listNpmPackages (#596)
1 parent 2b42ede commit 2004622

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { expect } from 'chai';
2+
import { listNpmPackages } from './npm-packages';
3+
4+
describe('listNpmPackages', () => {
5+
it('lists packages', () => {
6+
const packages = listNpmPackages();
7+
expect(packages.length).to.be.greaterThan(1);
8+
for (const { name, version } of packages) {
9+
expect(name).to.be.a('string');
10+
expect(version).to.be.a('string');
11+
}
12+
});
13+
});

packages/build/src/npm-packages.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,17 @@ export function publishNpmPackages(): void {
5555
});
5656
}
5757

58-
function listNpmPackages(): {version: string}[] {
58+
export function listNpmPackages(): {name: string; version: string}[] {
5959
const lernaListOutput = spawn.sync(
6060
LERNA_BIN, [
6161
'list',
6262
'--json',
6363
],
6464
{
65-
cwd: PROJECT_ROOT
65+
cwd: PROJECT_ROOT,
66+
encoding: 'utf8'
6667
}
67-
).toString();
68+
);
6869

69-
return JSON.parse(lernaListOutput);
70+
return JSON.parse(lernaListOutput.stdout);
7071
}

0 commit comments

Comments
 (0)