File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,24 @@ const {
4
4
statSync,
5
5
writeFileSync,
6
6
} = require ( "node:fs" ) ;
7
+
8
+
9
+ const { spawnSync } = require ( "node:child_process" ) ;
10
+
7
11
const { join } = require ( "node:path" ) ;
8
12
9
13
const crawl = ( path , json ) => {
10
14
for ( const file of readdirSync ( path ) ) {
11
15
const full = join ( path , file ) ;
12
- if ( / \. p y $ / . test ( file ) ) json [ file ] = readFileSync ( full ) . toString ( ) ;
16
+ if ( / \. p y $ / . test ( file ) ) {
17
+ if ( process . env . NO_MIN )
18
+ json [ file ] = readFileSync ( full ) . toString ( ) ;
19
+ else {
20
+ const { output : [ error , result ] } = spawnSync ( 'pyminify' , [ full ] ) ;
21
+ if ( error ) process . exit ( 1 ) ;
22
+ json [ file ] = result . toString ( ) ;
23
+ }
24
+ }
13
25
else if ( statSync ( full ) . isDirectory ( ) && ! file . endsWith ( "_" ) )
14
26
crawl ( full , ( json [ file ] = { } ) ) ;
15
27
}
Original file line number Diff line number Diff line change @@ -11,3 +11,5 @@ micropip==0.5.0
11
11
toml == 0.10.2
12
12
numpy == 1.26.4
13
13
pillow == 10.3.0
14
+ python-minifier == 2.9.0
15
+ setuptools =72.1.0
You can’t perform that action at this time.
0 commit comments