This repository was archived by the owner on Jun 1, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +47
-4
lines changed
Expand file tree Collapse file tree 4 files changed +47
-4
lines changed Original file line number Diff line number Diff line change 11. *
22index.ts
3- tsconfig.json
3+ tsconfig.json
4+ * .dev.js
5+ src /
6+ tsconfig.eslint.json
Original file line number Diff line number Diff line change 1111 "build" : " tsc" ,
1212 "build:check" : " tsc --noEmit --incremental false" ,
1313 "npm:publish" : " npm publish --access public" ,
14- "download" : " node script/download" ,
15- "postinstall" : " (is-ci && npm run download) || (npm run build && npm run download && husky install)"
14+ "postinstall:prod" : " node script/download" ,
15+ "postinstall" : " npm run build && node script/download && husky install" ,
16+ "prepublishOnly" : " node script/prepublishOnly.dev" ,
17+ "postpublish" : " node script/postpublish.dev"
1618 },
1719 "repository" : {
1820 "type" : " git" ,
4850 "distube" : " ^3.3.2" ,
4951 "eslint" : " ^8.8.0" ,
5052 "eslint-config-distube" : " ^1.6.3" ,
53+ "fromentries" : " ^1.3.2" ,
5154 "husky" : " ^7.0.4" ,
52- "is-ci" : " ^3.0.1" ,
5355 "nano-staged" : " ^0.5.0" ,
5456 "prettier" : " ^2.5.1" ,
5557 "typescript" : " ^4.5.5"
Original file line number Diff line number Diff line change 1+ const fs = require ( "fs" ) ;
2+ const path = require ( "path" ) ;
3+ const fromEntries = require ( "fromentries" ) ;
4+
5+ function fn ( name ) {
6+ if ( name === "postinstall:dev" ) return "postinstall" ;
7+ else if ( name === "postinstall" ) return "postinstall:prod" ;
8+ return name ;
9+ }
10+
11+ const file = path . join ( process . cwd ( ) , "package.json" ) ;
12+ let data = fs . readFileSync ( file , "utf-8" ) ;
13+ const pkg = JSON . parse ( data ) ;
14+ pkg . scripts = fromEntries ( Object . entries ( pkg . scripts ) . map ( ( [ key , value ] ) => [ fn ( key ) , value ] ) ) ;
15+ const regex = / ^ [ ] + | \t + / m;
16+ const res = regex . exec ( data ) ;
17+ const indent = res ? res [ 0 ] : null ;
18+ data = JSON . stringify ( pkg , null , indent ) ;
19+ fs . writeFileSync ( file , `${ data } \n` ) ;
Original file line number Diff line number Diff line change 1+ const fs = require ( "fs" ) ;
2+ const path = require ( "path" ) ;
3+ const fromEntries = require ( "fromentries" ) ;
4+
5+ function fn ( name ) {
6+ if ( name === "postinstall:prod" ) return "postinstall" ;
7+ else if ( name === "postinstall" ) return "postinstall:dev" ;
8+ return name ;
9+ }
10+
11+ const file = path . join ( process . cwd ( ) , "package.json" ) ;
12+ let data = fs . readFileSync ( file , "utf-8" ) ;
13+ const pkg = JSON . parse ( data ) ;
14+ pkg . scripts = fromEntries ( Object . entries ( pkg . scripts ) . map ( ( [ key , value ] ) => [ fn ( key ) , value ] ) ) ;
15+ const regex = / ^ [ ] + | \t + / m;
16+ const res = regex . exec ( data ) ;
17+ const indent = res ? res [ 0 ] : null ;
18+ data = JSON . stringify ( pkg , null , indent ) ;
19+ fs . writeFileSync ( file , `${ data } \n` ) ;
You can’t perform that action at this time.
0 commit comments