diff --git a/packages/build/src/npm-packages.spec.ts b/packages/build/src/npm-packages.spec.ts new file mode 100644 index 000000000..7b5f42646 --- /dev/null +++ b/packages/build/src/npm-packages.spec.ts @@ -0,0 +1,13 @@ +import { expect } from 'chai'; +import { listNpmPackages } from './npm-packages'; + +describe('listNpmPackages', () => { + it('lists packages', () => { + const packages = listNpmPackages(); + expect(packages.length).to.be.greaterThan(1); + for (const { name, version } of packages) { + expect(name).to.be.a('string'); + expect(version).to.be.a('string'); + } + }); +}); diff --git a/packages/build/src/npm-packages.ts b/packages/build/src/npm-packages.ts index 378da591d..fe1d5ca62 100644 --- a/packages/build/src/npm-packages.ts +++ b/packages/build/src/npm-packages.ts @@ -55,16 +55,17 @@ export function publishNpmPackages(): void { }); } -function listNpmPackages(): {version: string}[] { +export function listNpmPackages(): {name: string; version: string}[] { const lernaListOutput = spawn.sync( LERNA_BIN, [ 'list', '--json', ], { - cwd: PROJECT_ROOT + cwd: PROJECT_ROOT, + encoding: 'utf8' } - ).toString(); + ); - return JSON.parse(lernaListOutput); + return JSON.parse(lernaListOutput.stdout); }