Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit 79ee0cc

Browse files
committed
fix(base): Move updateDependencies to prepare command and fix it
1 parent 9758c29 commit 79ee0cc

1 file changed

Lines changed: 22 additions & 18 deletions

File tree

src/lib/base.ts

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export class Base {
125125
await this.linkNpmClear(customOptions),
126126
await this.linkDist(customOptions),
127127
await this.linkNpmClear(customOptions),
128-
await this.updateDependencies(customOptions),
129128
];
130129
this.log('link').debug('end');
131130
return items.reduce((all: boolean, current: boolean) => { return all && current; }, true);
@@ -226,45 +225,49 @@ export class Base {
226225
this.log('changeVersion').debug('end');
227226
return await true;
228227
}
229-
async updateDependencies(customOptions?: { rootPackagePath?: string, distPackagePath?: string }) {
228+
async updateDependencies(customOptions?: { rootPackagePath?: string, srcPackagePath?: string }) {
230229
this.log('updateDependencies').debug('start');
231230
let rootPackagePath = path.resolve(this.rootFolder + '/package.json');
232-
let distPackagePath = path.resolve(this.folder + '/dist/package.json');
231+
let srcPackagePath = path.resolve(this.folder + '/src/package.json');
233232
if (customOptions && customOptions.rootPackagePath) {
234233
rootPackagePath = customOptions.rootPackagePath;
235234
}
236-
if (customOptions && customOptions.distPackagePath) {
237-
distPackagePath = customOptions.distPackagePath;
235+
if (customOptions && customOptions.srcPackagePath) {
236+
srcPackagePath = customOptions.srcPackagePath;
238237
}
239238

239+
this.log('updateDependencies').debug('rootPackagePath', rootPackagePath);
240+
this.log('updateDependencies').debug('srcPackagePath', srcPackagePath);
241+
240242
let rootPackage: any = null;
241-
let distPackage: any = null;
243+
let srcPackage: any = null;
242244

243245
if (fsExtra.existsSync(rootPackagePath)) {
244246
rootPackage = fsExtra.readJSONSync(rootPackagePath);
245247
}
246-
if (fsExtra.existsSync(distPackagePath)) {
247-
distPackage = fsExtra.readJSONSync(distPackagePath);
248+
if (fsExtra.existsSync(srcPackagePath)) {
249+
srcPackage = fsExtra.readJSONSync(srcPackagePath);
248250
}
249-
if (rootPackage && distPackage) {
251+
if (rootPackage && srcPackage) {
250252
for (let key in rootPackage) {
251253
if (key.toLowerCase().indexOf('dependencies') !== -1) {
252254
let dependencies = rootPackage[key];
253-
if (distPackage[key]) {
255+
if (srcPackage[key]) {
254256
for (let devKey in dependencies) {
255-
if (distPackage[key][devKey] === '*') {
256-
distPackage[key][devKey] = dependencies[devKey];
257-
if (key === 'dependencies' &&
258-
distPackage['peerDependencies'] &&
259-
distPackage['peerDependencies'][devKey] === '*') {
260-
distPackage['peerDependencies'][devKey] = dependencies[devKey];
261-
}
257+
if (srcPackage[key][devKey] !== undefined) {
258+
srcPackage[key][devKey] = dependencies[devKey];
259+
}
260+
if (key === 'dependencies' &&
261+
srcPackage['peerDependencies'] &&
262+
srcPackage['peerDependencies'][devKey] !== undefined) {
263+
srcPackage['peerDependencies'][devKey] = dependencies[devKey];
262264
}
263265
}
264266
}
265267
}
266268
}
267-
fsExtra.writeJSONSync(distPackagePath, distPackage, { spaces: 4 });
269+
this.log('updateDependencies').debug('srcPackage', srcPackage);
270+
fsExtra.writeJSONSync(srcPackagePath, srcPackage, { spaces: 4 });
268271
this.log('updateDependencies').debug('writeJSONSync');
269272
}
270273
this.log('updateDependencies').debug('end');
@@ -337,6 +340,7 @@ export class Base {
337340
await this.extractTranslate(customOptions),
338341
await this.makeTsList(customOptions),
339342
await this.makeTsList(customOptions),
343+
await this.updateDependencies(customOptions),
340344
await this.changeVersion(customOptions)
341345
];
342346
this.log('prepare').debug('end');

0 commit comments

Comments
 (0)