-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from goestav/feature/support-multiple-package…
…-managers Feature: support multiple package managers
- Loading branch information
Showing
5 changed files
with
2,726 additions
and
2,159 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,5 @@ | ||
--- | ||
"@arethetypeswrong/cli": minor | ||
--- | ||
|
||
Add support for multiple package managers like [pnpm](https://pnpm.io/) and [yarn](https://yarnpkg.com/) ([#173](https://github.com/arethetypeswrong/arethetypeswrong.github.io/issues/173)) |
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,26 @@ | ||
import { readFile } from "fs/promises"; | ||
import path from "path"; | ||
|
||
/** Determine which CLI command to use to create a tarball from a package. */ | ||
export const determinePackCommand = (packageManager: string, filename?: string) => { | ||
switch (packageManager) { | ||
case "pnpm": | ||
// PNPM does not support custom destination filenames (see: https://github.com/pnpm/pnpm/issues/7834) | ||
return "pnpm pack"; | ||
case "yarn": | ||
return filename ? `yarn pack --out ${filename}` : "yarn pack"; | ||
default: | ||
return filename ? `npm pack ${filename}` : "npm pack"; | ||
} | ||
}; | ||
|
||
/** Determine which tarball filename to use. */ | ||
export const determineTarballFilename = async (fileOrDirectory: string) => { | ||
const manifest = JSON.parse(await readFile(path.join(fileOrDirectory, "package.json"), { encoding: "utf8" })); | ||
|
||
return path.join( | ||
fileOrDirectory, | ||
// https://github.com/npm/cli/blob/f875caa86900122819311dd77cde01c700fd1817/lib/utils/tar.js#L123-L125 | ||
`${manifest.name.replace("@", "").replace("/", "-")}-${manifest.version}.tgz`, | ||
); | ||
}; |
Oops, something went wrong.