chore(es/minifier): Add a script to copy tests from a next.js app (#2778)

This commit is contained in:
Donny/강동윤 2021-11-17 16:18:34 +09:00 committed by GitHub
parent 8c04d396e4
commit e1b76654f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 1 deletions

View File

@ -16,6 +16,7 @@
"devDependencies": {
"antd": "^4.16.13",
"babel-eslint": "^10.1.0",
"eslint": "^7.29.0"
"eslint": "^7.29.0",
"readline": "^1.3.0"
}
}

View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -eu
# Usage: Invoke this script using full path from a next app.
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
export NEXT_DEBUG_MINIFY=1
# Remove preovious builds
rm -r .next
npx next build | grep '{ name:' | node "$SCRIPT_DIR/evaluate.js"

View File

@ -0,0 +1,24 @@
const readline = require('readline');
const fs = require('fs').promises;
const path = require('path');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on('line', async (data) => {
try {
const { name, source } = eval(`(${data})`)
const targetPath = path.join(__dirname, '..', '..', 'tests', 'compress', 'fixture', 'issues', 'next', name);
await fs.mkdir(path.dirname(targetPath), { recursive: true });
await fs.writeFile(targetPath, source, 'utf8');
} catch (e) {
console.log(`Code: (${data})`)
console.error(e);
}
})

View File

@ -1243,6 +1243,11 @@ react-is@^16.12.0:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
readline@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/readline/-/readline-1.3.0.tgz#c580d77ef2cfc8752b132498060dc9793a7ac01c"
integrity sha1-xYDXfvLPyHUrEySYBg3JeTp6wBw=
regenerator-runtime@^0.13.4:
version "0.13.9"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52"