monorepo-build
Version:
Builds a monorepo.
35 lines (34 loc) • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("./index");
const tmp = require("tmp");
jest.mock('./util/exec', () => {
const { execSync: _execSync } = require('child_process');
return {
calls: [],
execSync(cwd, command) {
this.calls.push({ command });
if (!command.includes('lerna')) {
return _execSync(command, { cwd });
}
// TODO: mock git clone
return _execSync('echo', { cwd });
},
};
});
describe('build', () => {
it('should build a project', () => {
const execUtil = require('./util/exec');
execUtil.calls = [];
const preRepkg = jest.fn(), postRepkg = jest.fn();
// TODO: have publish return packages and snapshot that value
index_1.build(tmp.dirSync().name, 'https://github.com/facebookincubator/create-react-app.git', 'HEAD', {
exclude: ['create-react-app'],
preRepkg,
postRepkg,
});
expect(execUtil.calls).toMatchSnapshot();
expect(preRepkg.mock.calls.length).toBe(1);
expect(postRepkg.mock.calls.length).toBe(1);
});
});