File tree 4 files changed +25
-25
lines changed 4 files changed +25
-25
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,12 @@ const fs = require('fs');
4
4
const path = require ( 'path' ) ;
5
5
6
6
const babel = require ( '@babel/core' ) ;
7
- const prettier = require ( 'prettier' ) ;
8
7
9
- const { readdirRecursive , showDirStats } = require ( './utils.js' ) ;
10
-
11
- const prettierConfig = JSON . parse (
12
- fs . readFileSync ( require . resolve ( '../.prettierrc' ) , 'utf-8' ) ,
13
- ) ;
8
+ const {
9
+ writeGeneratedFile ,
10
+ readdirRecursive ,
11
+ showDirStats ,
12
+ } = require ( './utils.js' ) ;
14
13
15
14
if ( require . main === module ) {
16
15
fs . rmSync ( './denoDist' , { recursive : true , force : true } ) ;
@@ -34,8 +33,3 @@ if (require.main === module) {
34
33
35
34
showDirStats ( './denoDist' ) ;
36
35
}
37
-
38
- function writeGeneratedFile ( filepath , body ) {
39
- const formatted = prettier . format ( body , { filepath, ...prettierConfig } ) ;
40
- fs . writeFileSync ( filepath , formatted ) ;
41
- }
Original file line number Diff line number Diff line change @@ -6,13 +6,12 @@ const assert = require('assert');
6
6
7
7
const ts = require ( 'typescript' ) ;
8
8
const babel = require ( '@babel/core' ) ;
9
- const prettier = require ( 'prettier' ) ;
10
9
11
- const { readdirRecursive , showDirStats } = require ( './utils.js' ) ;
12
-
13
- const prettierConfig = JSON . parse (
14
- fs . readFileSync ( require . resolve ( '../.prettierrc' ) , 'utf-8' ) ,
15
- ) ;
10
+ const {
11
+ writeGeneratedFile ,
12
+ readdirRecursive ,
13
+ showDirStats ,
14
+ } = require ( './utils.js' ) ;
16
15
17
16
if ( require . main === module ) {
18
17
fs . rmSync ( './npmDist' , { recursive : true , force : true } ) ;
@@ -90,11 +89,6 @@ if (require.main === module) {
90
89
showDirStats ( './npmDist' ) ;
91
90
}
92
91
93
- function writeGeneratedFile ( filepath , body ) {
94
- const formatted = prettier . format ( body , { filepath, ...prettierConfig } ) ;
95
- fs . writeFileSync ( filepath , formatted ) ;
96
- }
97
-
98
92
function babelBuild ( srcPath , options ) {
99
93
const { code } = babel . transformFileSync ( srcPath , {
100
94
babelrc : false ,
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- const fs = require ( 'fs' ) ;
4
-
5
3
const { version } = require ( '../package.json' ) ;
6
4
5
+ const { writeGeneratedFile } = require ( './utils.js' ) ;
6
+
7
7
const versionMatch = / ^ ( \d + ) \. ( \d + ) \. ( \d + ) - ? ( .* ) ? $ / . exec ( version ) ;
8
8
if ( ! versionMatch ) {
9
9
throw new Error ( 'Version does not match semver spec: ' + version ) ;
@@ -34,5 +34,5 @@ export const versionInfo = Object.freeze({
34
34
` ;
35
35
36
36
if ( require . main === module ) {
37
- fs . writeFileSync ( './src/version.ts' , body . trim ( ) + '\n' ) ;
37
+ writeGeneratedFile ( './src/version.ts' , body ) ;
38
38
}
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ const fs = require('fs');
4
4
const path = require ( 'path' ) ;
5
5
const childProcess = require ( 'child_process' ) ;
6
6
7
+ const prettier = require ( 'prettier' ) ;
8
+
7
9
function exec ( command , options ) {
8
10
const output = childProcess . execSync ( command , {
9
11
maxBuffer : 10 * 1024 * 1024 , // 10MB
@@ -80,8 +82,18 @@ function showDirStats(dirPath) {
80
82
) ;
81
83
}
82
84
85
+ const prettierConfig = JSON . parse (
86
+ fs . readFileSync ( require . resolve ( '../.prettierrc' ) , 'utf-8' ) ,
87
+ ) ;
88
+
89
+ function writeGeneratedFile ( filepath , body ) {
90
+ const formatted = prettier . format ( body , { filepath, ...prettierConfig } ) ;
91
+ fs . writeFileSync ( filepath , formatted ) ;
92
+ }
93
+
83
94
module . exports = {
84
95
exec,
85
96
readdirRecursive,
86
97
showDirStats,
98
+ writeGeneratedFile,
87
99
} ;
You can’t perform that action at this time.
0 commit comments