Skip to content

Commit

Permalink
fix(cli): fix build error when manually deleting a model, repository …
Browse files Browse the repository at this point in the history
…or controller

- force a clean build in prestart npm script
- add rebuild script to more concisely express "clean && build" procedure & remove code duplication

fix loopbackio#3259

Signed-off-by: Mattia Primavera <[email protected]>
  • Loading branch information
MattiaPrimavera committed Oct 21, 2020
1 parent e45cfd3 commit f4d719d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
10 changes: 6 additions & 4 deletions packages/cli/generators/project/templates/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
<% } -%>
<% } -%>
<% if (packageManager === 'yarn') { -%>
"pretest": "yarn run clean && yarn run build",
"pretest": "yarn run rebuild",
<% } else { -%>
"pretest": "npm run clean && npm run build",
"pretest": "npm run rebuild",
<% } -%>
<% if (project.mocha) { -%>
"test": "lb-mocha --allow-console-logs \"dist/__tests__\"",
Expand Down Expand Up @@ -94,9 +94,11 @@
"preopenapi-spec": "npm run build",
"openapi-spec": "node ./dist/openapi-spec",
<% if (packageManager === 'yarn') { -%>
"prestart": "yarn run build",
"rebuild": "yarn run clean && yarn run build",
"prestart": "yarn run rebuild",
<% } else { -%>
"prestart": "npm run build",
"rebuild": "npm run clean && npm run build",
"prestart": "npm run rebuild",
<% } -%>
"start": "node -r source-map-support/register .",
<% } -%>
Expand Down
10 changes: 6 additions & 4 deletions packages/cli/generators/project/templates/package.plain.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
<% } -%>
<% } -%>
<% if (packageManager === 'yarn') { -%>
"pretest": "yarn run clean && yarn run build",
"pretest": "yarn run rebuild",
<% } else { -%>
"pretest": "npm run clean && npm run build",
"pretest": "npm run rebuild",
<% } -%>
<% if (project.mocha) { -%>
"test": "mocha dist/__tests__",
Expand Down Expand Up @@ -93,9 +93,11 @@
"migrate": "node ./dist/migrate",
"openapi-spec": "node ./dist/openapi-spec",
<% if (packageManager === 'yarn') { -%>
"prestart": "yarn run build",
"rebuild": "yarn run clean && yarn run build",
"prestart": "yarn run rebuild",
<% } else { -%>
"prestart": "npm run build",
"rebuild": "npm run clean && npm run build",
"prestart": "npm run rebuild",
<% } -%>
"start": "node -r source-map-support/register .",
<% } -%>
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/test/integration/lib/project-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ module.exports = function (projGenerator, props, projectType) {
);
assert.jsonFileContent('package.json', {
scripts: {
prestart: 'npm run build',
rebuild: 'npm run clean && npm run build',
prestart: 'npm run rebuild',
start: 'node -r source-map-support/register .',
},
});
Expand All @@ -296,7 +297,8 @@ module.exports = function (projGenerator, props, projectType) {
assert.noFileContent('package.json', '"@loopback/rest"');
assert.noFileContent('package.json', '"@loopback/openapi-v3"');
assert.noJsonFileContent('package.json', {
prestart: 'npm run build',
rebuild: 'npm run clean && npm run build',
prestart: 'npm run rebuild',
start: 'node .',
});
}
Expand Down

0 comments on commit f4d719d

Please sign in to comment.