Skip to content

Commit

Permalink
fix(snackager): skip importing node_modules files through picomatch
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric committed Feb 11, 2024
1 parent 63a549e commit b8c843a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions snackager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"memory-fs": "^0.4.1",
"metro-react-native-babel-preset": "^0.76.8",
"node-fetch": "^2.6.0",
"picomatch": "^4.0.1",
"querystring": "^0.2.0",
"raven": "^2.6.4",
"react-native-reanimated": "2.0.0-rc.3",
Expand Down
8 changes: 8 additions & 0 deletions snackager/src/utils/convertRepoToSnack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import fs from 'fs';
import GitUrlParse from 'git-url-parse';
import json5 from 'json5';
import path from 'path';
import picomatch from 'picomatch';
import { Snack } from 'snack-sdk';
import util from 'util';

Expand Down Expand Up @@ -136,6 +137,8 @@ async function generateFilesObj(dirname: string): Promise<GitSnackFiles> {
snackagerURL: config.url,
});

const isNodeModulesFile = picomatch('**/node_modules/**');

try {
await Promise.all(
localFiles.map(async (fileName) => {
Expand All @@ -152,6 +155,11 @@ async function generateFilesObj(dirname: string): Promise<GitSnackFiles> {
return;
}

// Skip node_modules files
if (isNodeModulesFile(fileName)) {
return;
}

if (isAsset(filePath)) {
const formData = new FormData();
formData.append('asset', fs.createReadStream(filePath), fileName);
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13337,6 +13337,11 @@ picomatch@^2.2.3:
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==

picomatch@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.1.tgz#68c26c8837399e5819edce48590412ea07f17a07"
integrity sha512-xUXwsxNjwTQ8K3GnT4pCJm+xq3RUPQbmkYJTP5aFIfNIvbcc/4MUxgBaaRSZJ6yGJZiGSyYlM6MzwTsRk8SYCg==

pify@^2.0.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
Expand Down Expand Up @@ -15262,6 +15267,13 @@ snack-babel-standalone@^3.0.1:
resolved "https://registry.yarnpkg.com/snack-babel-standalone/-/snack-babel-standalone-3.0.1.tgz#c619711c4e2e59b44846b28dbbdfdaaed76495c4"
integrity sha512-sqmBEX7kuW1ZwgviIYi06ILnVhDHCxiZk/DDrISejxUUyFnu3zXQxrYAwtWksj3v7VlGyC2TsALXQN3GhDi0Hg==

snack-content@*:
version "1.6.0"
resolved "https://registry.yarnpkg.com/snack-content/-/snack-content-1.6.0.tgz#a37af0b83e62510729c4e0e8365c588436933f84"
integrity sha512-Eq8j5/MTg98O6xYV77d1O9NLB3EVWSIuQwJd5S5QhK5MkBvINk41VRSwLsRfkEdZPVsbLflVHBqHhXuMHCaUCA==
dependencies:
semver "^7.3.4"

snack-eslint-standalone@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/snack-eslint-standalone/-/snack-eslint-standalone-2.0.0.tgz#99157a29b05eb4849ddaae1dde1c25363f43d899"
Expand Down

0 comments on commit b8c843a

Please sign in to comment.