Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Add force option. [closes #501]
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jul 14, 2018
1 parent 57d709a commit 36f47a9
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const defaultOptions = {
vars: false
},
debug: false,
force: false,
mainFields: ["main"],
mode: "strict",
sourceMap: void 0
Expand Down Expand Up @@ -349,6 +350,14 @@ function createOptions(value) {
throw new ERR_INVALID_ESM_OPTION("debug", debug)
}

const { force } = options

if (isFlag(force)) {
options.force = !! force
} else {
throw new ERR_INVALID_ESM_OPTION("force", cache)
}

const defaultMainFields = defaultOptions.mainFields

let { mainFields } = options
Expand Down Expand Up @@ -418,7 +427,14 @@ function findRoot(dirPath) {
}

function getInfo(dirPath, force) {
let pkg
const defaultPkg = Package.state.default

let pkg = null

if (defaultPkg &&
defaultPkg.options.force === true) {
return pkg
}

if (Reflect.has(Package.state.cache, dirPath)) {
pkg = Package.state.cache[dirPath]
Expand Down Expand Up @@ -518,6 +534,7 @@ function readInfo(dirPath, force) {
} finally {
moduleState.parseOnly = parseOnly
moduleState.parsing = parsing
Package.state.cache[dirPath] = null
}
}
}
Expand Down

0 comments on commit 36f47a9

Please sign in to comment.