Преглед на файлове

meta: fix missing EOL and end of e2e test templates (#3484)

Antoine du Hamel преди 3 години
родител
ревизия
c2692e4d3a
променени са 3 файла, в които са добавени 23 реда и са изтрити 9 реда
  1. 23 7
      e2e/generate-test.mjs
  2. 0 1
      e2e/package.json
  3. 0 1
      yarn.lock

+ 23 - 7
e2e/generate-test.mjs

@@ -2,7 +2,23 @@
 /* eslint-disable no-console, import/no-extraneous-dependencies */
 import prompts from 'prompts'
 import fs from 'node:fs/promises'
-import dedent from 'dedent'
+
+/**
+ * Utility function that strips indentation from multi-line strings.
+ * Inspired from https://github.com/dmnd/dedent.
+ */
+function dedent (strings, ...parts) {
+  const nonSpacingChar = /\S/m.exec(strings[0])
+  if (nonSpacingChar == null) return ''
+
+  const indent = nonSpacingChar.index - strings[0].lastIndexOf('\n', nonSpacingChar.index) - 1
+  const dedentEachLine = str => str.split('\n').map((line, i) => line.slice(i && indent)).join('\n')
+  let returnLines = dedentEachLine(strings[0].slice(nonSpacingChar.index), indent)
+  for (let i = 1; i < strings.length; i++) {
+    returnLines += String(parts[i - 1]) + dedentEachLine(strings[i], indent)
+  }
+  return returnLines
+}
 
 const packageNames = await fs.readdir(new URL('../packages/@uppy', import.meta.url))
 const unwantedPackages = ['core', 'companion', 'redux-dev-tools', 'utils']
@@ -54,14 +70,14 @@ const html = dedent`
 const appUrl = new URL(`clients/${name}/app.js`, import.meta.url)
 // dedent is acting weird for this one but this formatting fixes it.
 const app = dedent`
-import Uppy from '@uppy/core'
-${packages.map((pgk) => `import ${camelcase(pgk)} from '@uppy/${pgk}'`).join('\n')}
+    import Uppy from '@uppy/core'
+    ${packages.map((pgk) => `import ${camelcase(pgk)} from '@uppy/${pgk}'`).join('\n')}
 
-const uppy = new Uppy()
-   ${packages.map((pkg) => `.use(${camelcase(pkg)})`).join('\n\t')}
+    const uppy = new Uppy()
+      ${packages.map((pkg) => `.use(${camelcase(pkg)})`).join('\n\t')}
 
-// Keep this here to access uppy in tests
-window.uppy = uppy
+    // Keep this here to access uppy in tests
+    window.uppy = uppy
   `
 
 await fs.writeFile(testUrl, test)

+ 0 - 1
e2e/package.json

@@ -47,7 +47,6 @@
   "devDependencies": {
     "cypress": "^9.0.0",
     "cypress-file-upload": "^5.0.8",
-    "dedent": "^0.7.0",
     "deep-freeze": "^0.0.1",
     "parcel": "^2.0.1",
     "prompts": "^2.4.2",

+ 0 - 1
yarn.lock

@@ -17017,7 +17017,6 @@ __metadata:
     "@uppy/zoom": "workspace:^"
     cypress: ^9.0.0
     cypress-file-upload: ^5.0.8
-    dedent: ^0.7.0
     deep-freeze: ^0.0.1
     parcel: ^2.0.1
     prompts: ^2.4.2