fix: imply lerna packages dir if not in config (#700)

This commit is contained in:
Rhys Arkins 2017-08-19 06:50:53 +02:00 committed by GitHub
parent d72dccfbe1
commit 68033a7040
3 changed files with 23 additions and 1 deletions

View file

@ -58,7 +58,9 @@ async function checkForLerna(config) {
} }
config.logger.debug({ lernaJson }, 'Found lerna config'); config.logger.debug({ lernaJson }, 'Found lerna config');
try { try {
const packagesPath = lernaJson.packages[0].slice(0, -2); const packagesPath = lernaJson.packages
? lernaJson.packages[0].slice(0, -2)
: 'packages';
const lernaPackages = await config.api.getSubDirectories(packagesPath); const lernaPackages = await config.api.getSubDirectories(packagesPath);
if (lernaPackages.length === 0) { if (lernaPackages.length === 0) {
return {}; return {};

View file

@ -9,6 +9,15 @@ Object {
exports[`workers/repository/apis checkForLerna(config) ignores zero length lerna 1`] = `Object {}`; exports[`workers/repository/apis checkForLerna(config) ignores zero length lerna 1`] = `Object {}`;
exports[`workers/repository/apis checkForLerna(config) implies lerna package path 1`] = `
Object {
"lernaPackages": Array [
"a",
"b",
],
}
`;
exports[`workers/repository/apis checkForLerna(config) returns lerna package names 1`] = ` exports[`workers/repository/apis checkForLerna(config) returns lerna package names 1`] = `
Object { Object {
"lernaPackages": Array [ "lernaPackages": Array [

View file

@ -92,6 +92,17 @@ describe('workers/repository/apis', () => {
const res = await apis.checkForLerna(config); const res = await apis.checkForLerna(config);
expect(res).toMatchSnapshot(); expect(res).toMatchSnapshot();
}); });
it('implies lerna package path', async () => {
const config = {
api: {
getFileJson: jest.fn(() => ({})),
getSubDirectories: jest.fn(() => ['a', 'b']),
},
logger,
};
const res = await apis.checkForLerna(config);
expect(res).toMatchSnapshot();
});
it('returns lerna package names', async () => { it('returns lerna package names', async () => {
const config = { const config = {
api: { api: {