mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 10:17:23 -05:00
* Fix #2167 - Provide instructions to build the project * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c4e25d879e
commit
b2d1018db1
1
pyscript.core/package-lock.json
generated
1
pyscript.core/package-lock.json
generated
@@ -33,6 +33,7 @@
|
||||
"@xterm/addon-web-links": "^0.11.0",
|
||||
"bun": "^1.1.27",
|
||||
"chokidar": "^4.0.0",
|
||||
"codedent": "^0.1.2",
|
||||
"codemirror": "^6.0.1",
|
||||
"eslint": "^9.10.0",
|
||||
"flatted": "^3.3.1",
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
"@xterm/addon-web-links": "^0.11.0",
|
||||
"bun": "^1.1.27",
|
||||
"chokidar": "^4.0.0",
|
||||
"codedent": "^0.1.2",
|
||||
"codemirror": "^6.0.1",
|
||||
"eslint": "^9.10.0",
|
||||
"flatted": "^3.3.1",
|
||||
|
||||
@@ -9,20 +9,43 @@ const { spawnSync } = require("node:child_process");
|
||||
|
||||
const { join } = require("node:path");
|
||||
|
||||
const dedent = require("codedent");
|
||||
|
||||
const crawl = (path, json) => {
|
||||
for (const file of readdirSync(path)) {
|
||||
const full = join(path, file);
|
||||
if (/\.py$/.test(file)) {
|
||||
if (process.env.NO_MIN) json[file] = readFileSync(full).toString();
|
||||
else {
|
||||
const {
|
||||
output: [error, result],
|
||||
} = spawnSync("pyminify", [
|
||||
"--remove-literal-statements",
|
||||
full,
|
||||
]);
|
||||
if (error) process.exit(1);
|
||||
json[file] = result.toString();
|
||||
try {
|
||||
const {
|
||||
output: [error, result],
|
||||
} = spawnSync("pyminify", [
|
||||
"--remove-literal-statements",
|
||||
full,
|
||||
]);
|
||||
if (error) {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
json[file] = result.toString();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.log(
|
||||
dedent(`
|
||||
\x1b[1m⚠️ is your env activated?\x1b[0m
|
||||
\x1b[2mYou need a Python env to run \x1b[0mpyminify\x1b[2m.\x1b[0m
|
||||
\x1b[2mTo do so, you can try the following:\x1b[0m
|
||||
python -m venv env
|
||||
source env/bin/activate
|
||||
pip install --upgrade pip
|
||||
pip install --ignore-requires-python python-minifier
|
||||
pip install setuptools
|
||||
\x1b[2mand you can then try \x1b[0mnpm run build\x1b[2m again.\x1b[0m
|
||||
`),
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
} else if (statSync(full).isDirectory() && !file.endsWith("_"))
|
||||
crawl(full, (json[file] = {}));
|
||||
|
||||
Reference in New Issue
Block a user