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

Commit

Permalink
fix(create-expo-app): allow scoped template package names (#4750)
Browse files Browse the repository at this point in the history
* fix: allow scoped template package names

This change detects a scoped package name for templates and correctly determines its location.
Tested with `@realm/expo-template`

* refactor(create-expo-app): move package filename sanitization to separate method

* fix(create-expo-app): correct typo in sanitize method

* chore(create-expo-app): resolve linting issue

---------

Co-authored-by: Cedric van Putten <github@cedric.dev>
  • Loading branch information
takameyer and byCedric committed Aug 25, 2023
1 parent 26142c3 commit af2874c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/create-expo-app/src/utils/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ async function npmPackAsync(
try {
const json = JSON.parse(results);
if (Array.isArray(json) && json.every(isNpmPackageInfo)) {
return json;
return json.map(sanitizeNpmPackageFilename);
} else {
throw new Error(`Invalid response from npm: ${results}`);
}
Expand Down Expand Up @@ -234,6 +234,19 @@ function isNpmPackageInfo(item: any): item is NpmPackageInfo {
);
}

/**
* Adjust the tar filename in npm package info for `npm@<9.0.0`.
*
* @see https://github.com/npm/cli/issues/3405
*/
function sanitizeNpmPackageFilename(item: NpmPackageInfo): NpmPackageInfo {
if (item.filename.startsWith('@') && item.name.startsWith('@')) {
item.filename = item.filename.replace(/^@/, '').replace(/\//, '-');
}

return item;
}

async function fileExistsAsync(path: string): Promise<boolean> {
try {
const stat = await fs.promises.stat(path);
Expand Down

0 comments on commit af2874c

Please sign in to comment.