-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use helpers to manage npm commands
This also speeds up tests and avoids us checking that npm did what it is supposed to do.
- Loading branch information
1 parent
afcbdf7
commit d499c4d
Showing
4 changed files
with
48 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
refactor: use helpers to manage npm commands | ||
|
||
This change speeds up tests and avoids us checking that npm did what it is supposed to do. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { execa } from "execa"; | ||
|
||
/** | ||
* Helpers for running npm commands | ||
*/ | ||
export const npm = { | ||
/** Add and install a new devDependency into the local package.json. */ | ||
async addDevDep(packageName: string, versionRange = "latest"): Promise<void> { | ||
await execa( | ||
"npm", | ||
["install", `${packageName}@${versionRange}`, "--save-dev"], | ||
{ | ||
stdio: "inherit", | ||
} | ||
); | ||
}, | ||
|
||
/** Install all the dependencies in the local package.json. */ | ||
async install(): Promise<void> { | ||
await execa("npm", ["install"], { | ||
stdio: "inherit", | ||
}); | ||
}, | ||
}; |