@shipstatic/drop 2.13.0-beta.4 → 2.13.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -287,6 +287,11 @@ async function projectSource(files) {
287
287
  const matcher = ignore({ allowRelativePaths: true });
288
288
  for (const { file, parts } of rules) {
289
289
  const base = parts.slice(0, -1).join("/");
290
+ if (/[\r\n]/.test(base)) {
291
+ throw new Error(
292
+ "A folder in this project has a line break in its name, so its .gitignore can't be read. Rename the folder, then try again."
293
+ );
294
+ }
290
295
  const text = (await file.text()).replace(/^\uFEFF/, "");
291
296
  for (const line of text.split(/\r?\n/)) {
292
297
  const pattern = rebase(line, base);
@@ -1085,24 +1090,38 @@ async function processFiles(input, { limits, onStatus }) {
1085
1090
  }
1086
1091
 
1087
1092
  // src/entries.ts
1088
- async function traverseFileTree(entry, files, currentPath = "") {
1093
+ function unreadable(path) {
1094
+ return `We couldn't read ${path}. Make sure it's on this computer, then try again.`;
1095
+ }
1096
+ async function readOrRefuse(path, read) {
1089
1097
  try {
1090
- if (entry.isFile) {
1091
- const file = await new Promise((resolve, reject) => {
1098
+ return await read();
1099
+ } catch {
1100
+ throw new Error(unreadable(path));
1101
+ }
1102
+ }
1103
+ async function traverseFileTree(entry, files, currentPath = "") {
1104
+ if (entry.isFile) {
1105
+ const path = currentPath ? `${currentPath}/${entry.name}` : entry.name;
1106
+ const file = await readOrRefuse(
1107
+ path,
1108
+ () => new Promise((resolve, reject) => {
1092
1109
  entry.file(resolve, reject);
1093
- });
1094
- setRelativePath(file, currentPath ? `${currentPath}/${file.name}` : file.name);
1095
- files.push(file);
1096
- return;
1097
- }
1098
- if (!entry.isDirectory) return;
1099
- for (const child of await readDirectory(entry)) {
1100
- if (child.isDirectory && child.name === "node_modules") continue;
1101
- const childPath = child.isDirectory ? currentPath ? `${currentPath}/${child.name}` : child.name : currentPath;
1102
- await traverseFileTree(child, files, childPath);
1103
- }
1104
- } catch (error) {
1105
- console.warn(`Error traversing file tree for entry ${entry.name}:`, error);
1110
+ })
1111
+ );
1112
+ setRelativePath(file, path);
1113
+ files.push(file);
1114
+ return;
1115
+ }
1116
+ if (!entry.isDirectory) return;
1117
+ const children = await readOrRefuse(
1118
+ currentPath || entry.name,
1119
+ () => readDirectory(entry)
1120
+ );
1121
+ for (const child of children) {
1122
+ if (child.isDirectory && child.name === "node_modules") continue;
1123
+ const childPath = child.isDirectory ? currentPath ? `${currentPath}/${child.name}` : child.name : currentPath;
1124
+ await traverseFileTree(child, files, childPath);
1106
1125
  }
1107
1126
  }
1108
1127
  async function readDirectory(directory) {