Skip to content

Commit

Permalink
Create the prefix install directory to support npm >= 7 #123
Browse files Browse the repository at this point in the history
  • Loading branch information
deepy committed Nov 13, 2020
1 parent aa4ec82 commit 6866083
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ open class NpmSetupTask : DefaultTask() {

protected open fun computeCommand(): List<String> {
val version = nodeExtension.npmVersion.get()
return listOf("install", "--global", "--no-save", "--prefix", npmDir.get().asFile.absolutePath,
val directory = npmDir.get().asFile
// npm < 7 creates the directory if it's missing, >= 7 fails if it's missing
directory.mkdirs()
return listOf("install", "--global", "--no-save", "--prefix", directory.absolutePath,
"npm@$version") + args.get()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ open class YarnSetupTask : NpmSetupTask() {
val version = nodeExtension.yarnVersion.get()
val yarnDir = yarnDir.get()
val yarnPackage = if (version.isNotBlank()) "yarn@$version" else "yarn"
// npm < 7 creates the directory if it's missing, >= 7 fails if it's missing
// create the directory since we use npm to install yarn.
yarnDir.asFile.mkdirs()
return listOf("install", "--global", "--no-save", "--prefix", yarnDir.asFile.absolutePath, yarnPackage)
.plus(args.get())
}
Expand Down

0 comments on commit 6866083

Please sign in to comment.