Skip to content

Commit 8a48029

Browse files
authored
Merge pull request #17 from netlify/feat/use-packagejson
Use `packageJson`
2 parents 8efbebb + 697f8b6 commit 8a48029

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

index.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const isStaticExportProject = require('./helpers/isStaticExportProject');
1515
// - Between the build and postbuild steps, any functions are bundled
1616

1717
module.exports = {
18-
async onPreBuild({ constants, netlifyConfig, utils }) {
18+
async onPreBuild({ netlifyConfig, packageJson: { scripts = {}, dependencies = {} }, utils }) {
1919
if (!(await hasFramework('next'))) {
2020
return failBuild(`This application does not use Next.js.`);
2121
}
@@ -27,21 +27,6 @@ module.exports = {
2727
// the next-on-netlify function template
2828
await utils.run.command('npm install next-on-netlify@latest');
2929

30-
// Require the project's package.json for access to its scripts
31-
// and dependencies in order to check existing project configuration
32-
let packageJson;
33-
if (existsSync(path.resolve(constants.PUBLISH_DIR, 'package.json'))) {
34-
packageJson = require(path.resolve(constants.PUBLISH_DIR, 'package.json'));
35-
} else if (existsSync(path.resolve(constants.PUBLISH_DIR, '..', 'package.json'))) {
36-
packageJson = require(path.resolve(constants.PUBLISH_DIR, '..', 'package.json'));
37-
} else {
38-
failBuild(`Cannot locate your package.json file. Please make sure your package.json is
39-
at the root of your project or in your publish directory.`
40-
);
41-
}
42-
43-
const { scripts, dependencies } = packageJson;
44-
4530
if (isStaticExportProject({ build, scripts })) {
4631
failBuild(`** Static HTML export next.js projects do not require this plugin **`);
4732
}

0 commit comments

Comments
 (0)