Skip to content
This repository was archived by the owner on Dec 4, 2022. It is now read-only.

Commit ff4feb5

Browse files
amitgilad3GiladShoham
authored andcommitted
Bug/no package json (#45)
1 parent d02b2e6 commit ff4feb5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/package-json/package-json.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,21 +200,21 @@ export default class PackageJson {
200200
* adds workspaces with private flag if dosent exist.
201201
*/
202202
static async addWorkspacesToPackageJson(rootDir: string, componentsDefaultDirectory: string, dependenciesDirectory: string, customImportPath: ?string ) {
203-
const pkg = await PackageJson.getPackageJson(rootDir) ;
204-
pkg.private = pkg.private || true;
203+
const pkg = (await PackageJson.getPackageJson(rootDir)) || {} ;
205204
const workSpaces = pkg.workspaces || [];
206205
workSpaces.push(dependenciesDirectory);
207206
workSpaces.push(componentsDefaultDirectory);
208207
if(customImportPath) workSpaces.push(customImportPath);
209208
pkg.workspaces = R.uniq(workSpaces);
209+
pkg.private = pkg.workspaces ? true : false;
210210
await PackageJson.saveRawObject(rootDir, pkg);
211211
}
212212

213213
/*
214214
* remove workspaces dir from workspace in package.json with changing other fields in package.json
215215
*/
216216
static async removeComponentsFromWorkspaces(rootDir: string, pathsTOoRemove: string[] ) {
217-
const pkg = await PackageJson.getPackageJson(rootDir);
217+
const pkg = (await PackageJson.getPackageJson(rootDir)) || {};
218218
let workSpaces = pkg.workspaces || [];
219219
pkg.workspaces = workSpaces.filter(folder => !pathsTOoRemove.includes(folder))
220220
await PackageJson.saveRawObject(rootDir, pkg);

0 commit comments

Comments
 (0)