Skip to content

Commit 9a3e2ef

Browse files
addaleaxrose-m
andauthored
fix(build): fix markBumpedFilesAsAssumeUnchanged file location (#604)
Co-authored-by: Michael Rose <[email protected]>
1 parent adc916e commit 9a3e2ef

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

packages/build/src/npm-packages.spec.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
listNpmPackages,
77
markBumpedFilesAsAssumeUnchanged,
88
publishNpmPackages,
9-
spawnSync
9+
spawnSync,
10+
LernaPackageDescription
1011
} from './npm-packages';
1112

1213

@@ -58,6 +59,11 @@ describe('npm-packages', () => {
5859
['version', '0.7.0', '--no-changelog', '--no-push', '--exact', '--no-git-tag-version', '--force-publish', '--yes'],
5960
sinon.match.any
6061
);
62+
expect(spawnSync).to.have.been.calledWith(
63+
'git',
64+
['status', '--porcelain'],
65+
sinon.match.any
66+
);
6167
});
6268
});
6369

@@ -167,16 +173,18 @@ describe('npm-packages', () => {
167173
});
168174

169175
describe('markBumpedFilesAsAssumeUnchanged', () => {
170-
let packages: { name: string; version: string }[];
176+
let packages: LernaPackageDescription[];
171177
let expectedFiles: string[];
172178
let spawnSync: SinonStub;
173179

174180
beforeEach(() => {
175-
expectedFiles = ['lerna.json'];
181+
expectedFiles = [
182+
path.resolve(__dirname, '..', '..', '..', 'lerna.json')
183+
];
176184
packages = listNpmPackages();
177-
packages.forEach(({ name }) => {
178-
expectedFiles.push(`packages/${name}/package.json`);
179-
expectedFiles.push(`packages/${name}/package-lock.json`);
185+
packages.forEach(({ location }) => {
186+
expectedFiles.push(path.resolve(location, 'package.json'));
187+
expectedFiles.push(path.resolve(location, 'package-lock.json'));
180188
});
181189

182190
spawnSync = sinon.stub();

packages/build/src/npm-packages.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ const PLACEHOLDER_VERSION = '0.0.0-dev.0';
66
const PROJECT_ROOT = path.resolve(__dirname, '..', '..', '..');
77
const LERNA_BIN = path.resolve(PROJECT_ROOT, 'node_modules', '.bin', 'lerna');
88

9+
export interface LernaPackageDescription {
10+
name: string;
11+
version: string;
12+
private: boolean;
13+
location: string;
14+
}
15+
916
export function spawnSync(command: string, args: string[], options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string> {
1017
const result = spawn.sync(command, args, options);
1118
if (result.error) {
@@ -46,6 +53,11 @@ export function bumpNpmPackages(
4653
cwd: PROJECT_ROOT,
4754
encoding: 'utf8'
4855
});
56+
spawnSyncFn('git', ['status', '--porcelain'], {
57+
stdio: 'inherit',
58+
cwd: PROJECT_ROOT,
59+
encoding: 'utf8'
60+
});
4961
}
5062

5163
export function publishNpmPackages(
@@ -88,11 +100,12 @@ export function publishNpmPackages(
88100
}
89101
}
90102

91-
export function listNpmPackages(): { name: string; version: string }[] {
103+
export function listNpmPackages(): LernaPackageDescription[] {
92104
const lernaListOutput = spawnSync(
93105
LERNA_BIN, [
94106
'list',
95107
'--json',
108+
'--all'
96109
],
97110
{
98111
cwd: PROJECT_ROOT,
@@ -104,15 +117,16 @@ export function listNpmPackages(): { name: string; version: string }[] {
104117
}
105118

106119
export function markBumpedFilesAsAssumeUnchanged(
107-
packages: { name: string }[], assumeUnchanged: boolean,
120+
packages: LernaPackageDescription[],
121+
assumeUnchanged: boolean,
108122
spawnSyncFn: typeof spawnSync = spawnSync
109123
): void {
110124
const filesToAssume = [
111-
'lerna.json'
125+
path.resolve(PROJECT_ROOT, 'lerna.json')
112126
];
113-
packages.forEach(({ name }) => {
114-
filesToAssume.push(`packages/${name}/package.json`);
115-
filesToAssume.push(`packages/${name}/package-lock.json`);
127+
packages.forEach(({ location }) => {
128+
filesToAssume.push(path.resolve(location, 'package.json'));
129+
filesToAssume.push(path.resolve(location, 'package-lock.json'));
116130
});
117131

118132
filesToAssume.forEach(f => {

0 commit comments

Comments
 (0)