@shipstatic/drop 2.13.0-beta.3 → 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
@@ -276,6 +276,7 @@ function rebase(line, base) {
276
276
  let body = negated ? pattern.slice(1) : pattern;
277
277
  const directoryOnly = body.endsWith("/");
278
278
  if (directoryOnly) body = body.slice(0, -1);
279
+ if (body.replace(/^\//, "") === "") return null;
279
280
  const rebased = body.includes("/") ? `${folder}/${body.replace(/^\//, "")}` : `${folder}/**/${body}`;
280
281
  return `${negated ? "!" : ""}${rebased}${directoryOnly ? "/" : ""}`;
281
282
  }
@@ -286,6 +287,11 @@ async function projectSource(files) {
286
287
  const matcher = ignore({ allowRelativePaths: true });
287
288
  for (const { file, parts } of rules) {
288
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
+ }
289
295
  const text = (await file.text()).replace(/^\uFEFF/, "");
290
296
  for (const line of text.split(/\r?\n/)) {
291
297
  const pattern = rebase(line, base);
@@ -1019,7 +1025,7 @@ async function processFiles(input, { limits, onStatus }) {
1019
1025
  needsBuild: true,
1020
1026
  status: {
1021
1027
  title: "Ready",
1022
- details: `${pluralize(ready.length, "file", "files", true)} ready \u2014 project will be built`
1028
+ details: `${pluralize(ready.length, "file", "files", true)} ready. We'll build the project.`
1023
1029
  }
1024
1030
  };
1025
1031
  }
@@ -1084,24 +1090,38 @@ async function processFiles(input, { limits, onStatus }) {
1084
1090
  }
1085
1091
 
1086
1092
  // src/entries.ts
1087
- 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) {
1088
1097
  try {
1089
- if (entry.isFile) {
1090
- 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) => {
1091
1109
  entry.file(resolve, reject);
1092
- });
1093
- setRelativePath(file, currentPath ? `${currentPath}/${file.name}` : file.name);
1094
- files.push(file);
1095
- return;
1096
- }
1097
- if (!entry.isDirectory) return;
1098
- for (const child of await readDirectory(entry)) {
1099
- if (child.isDirectory && child.name === "node_modules") continue;
1100
- const childPath = child.isDirectory ? currentPath ? `${currentPath}/${child.name}` : child.name : currentPath;
1101
- await traverseFileTree(child, files, childPath);
1102
- }
1103
- } catch (error) {
1104
- 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);
1105
1125
  }
1106
1126
  }
1107
1127
  async function readDirectory(directory) {