Skip to content

Commit

Permalink
Removed invalid package.json check
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Simko committed Feb 15, 2021
1 parent fd093c8 commit dfcc108
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
22 changes: 10 additions & 12 deletions lib/migrations/util/is-module-type.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
const { readFile } = require('./fs');

module.exports = async function isModuleType(filepath) {
try {
if (process.env.npm_package_json) {
// npm >= 7.0.0
const packageJson = JSON.parse(await readFile(process.env.npm_package_json, 'utf-8'));
if (packageJson.type === 'module') {
return true;
}
}
} catch (e) {
console.warn('Error reading package.json', e);
if (process.env.npm_package_json) {
// npm >= 7.0.0
const packageJson = JSON.parse(
await readFile(process.env.npm_package_json, 'utf-8')
);
if (packageJson.type === 'module') {
return true;
}
return process.env.npm_package_type === 'module' || filepath.endsWith('.mjs')
}
}
return process.env.npm_package_type === 'module' || filepath.endsWith('.mjs');
};
4 changes: 0 additions & 4 deletions test/unit/migrations/util/test/package-invalid.json

This file was deleted.

0 comments on commit dfcc108

Please sign in to comment.