Skip to content

Commit

Permalink
fix(react): do not include package.json in libs without publishable f…
Browse files Browse the repository at this point in the history
…lag (#2896)
  • Loading branch information
Cammisuli committed Apr 27, 2020
1 parent 78a9fee commit b4fc65c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions e2e/react.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ forEachCli(currentCLIName => {
);
runCLI(`generate @nrwl/react:lib ${libName} --no-interactive`);

// Libs should not include package.json by default
checkFilesDoNotExist(`libs/${libName}/package.json`);

const mainPath = `apps/${appName}/src/main.tsx`;
updateFile(mainPath, `import '@proj/${libName}';\n` + readFile(mainPath));

Expand Down
1 change: 1 addition & 0 deletions packages/react/src/schematics/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe('lib', () => {

it('should generate files', async () => {
const tree = await runSchematic('lib', { name: 'myLib' }, appTree);
expect(tree.exists('libs/my-lib/package.json')).toBeFalsy();
expect(tree.exists(`libs/my-lib/jest.config.js`)).toBeTruthy();
expect(tree.exists('libs/my-lib/src/index.ts')).toBeTruthy();
expect(tree.exists('libs/my-lib/src/lib/my-lib.tsx')).toBeTruthy();
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/schematics/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default function(schema: Schema): Rule {
pascalCaseFiles: options.pascalCaseFiles
})
: noop(),
updateLibPackageNpmScope(options),
options.publishable ? updateLibPackageNpmScope(options) : noop(),
updateAppRoutes(options, context),
formatFiles(options)
])(host, context);
Expand Down

0 comments on commit b4fc65c

Please sign in to comment.