@@ -19,35 +19,39 @@ export class ProtonFramework extends LibUiFramework {
19
19
getDefaultIcon ( platform : Platform ) : string {
20
20
if ( platform === Platform . WINDOWS ) {
21
21
return getTemplatePath ( "icons/proton-native/proton-native.ico" )
22
- }
23
- else if ( platform === Platform . LINUX ) {
22
+ } else if ( platform === Platform . LINUX ) {
24
23
return getTemplatePath ( "icons/proton-native/linux" )
25
- }
26
- else {
24
+ } else {
27
25
return getTemplatePath ( "icons/proton-native/proton-native.icns" )
28
26
}
29
27
}
30
28
31
29
createTransformer ( ) : FileTransformer | null {
32
30
let babel : any
33
- const babelOptions : any = { ast : false , sourceMaps : "inline" }
31
+ const babelOptions : any = { ast : false , sourceMaps : "inline" }
34
32
if ( process . env . TEST_SET_BABEL_PRESET === "true" ) {
35
33
babel = require ( "@babel/core" )
36
34
// eslint-disable-next-line @typescript-eslint/no-use-before-define
37
35
babel = testOnlyBabel ( babel , babelOptions , this . version )
38
- }
39
- else {
36
+ } else {
40
37
try {
41
38
babel = require ( "babel-core" )
42
- }
43
- catch ( e ) {
39
+ } catch ( e ) {
44
40
// babel isn't installed
45
41
log . debug ( null , "don't transpile source code using Babel" )
46
42
return null
47
43
}
48
44
}
49
45
50
- log . info ( { options : safeStringifyJson ( babelOptions , new Set < string > ( [ "presets" ] ) ) } , "transpile source code using Babel" )
46
+ log . info (
47
+ {
48
+ options : safeStringifyJson (
49
+ babelOptions ,
50
+ new Set < string > ( [ "presets" ] ) ,
51
+ ) ,
52
+ } ,
53
+ "transpile source code using Babel" ,
54
+ )
51
55
return ( file ) : Promise < any > | null => {
52
56
if ( ! ( file . endsWith ( ".js" ) || file . endsWith ( ".jsx" ) ) || file . includes ( NODE_MODULES_PATTERN ) ) {
53
57
return null
@@ -57,8 +61,7 @@ export class ProtonFramework extends LibUiFramework {
57
61
return babel . transformFile ( file , babelOptions , ( error : Error , result : any ) => {
58
62
if ( error == null ) {
59
63
resolve ( result . code )
60
- }
61
- else {
64
+ } else {
62
65
reject ( error )
63
66
}
64
67
} )
@@ -69,24 +72,21 @@ export class ProtonFramework extends LibUiFramework {
69
72
70
73
function testOnlyBabel ( babel : any , babelOptions : any , nodeVersion : string ) : any {
71
74
// out test dir can be located outside of electron-builder node_modules and babel cannot resolve string names of preset
72
- babelOptions . presets = [
73
- [ require ( "@babel/preset-env" ) . default , { targets : { node : nodeVersion } } ] ,
74
- require ( "@babel/preset-react" ) ,
75
- ]
75
+ babelOptions . presets = [ [ require ( "@babel/preset-env" ) . default , { targets : { node : nodeVersion } } ] , require ( "@babel/preset-react" ) ]
76
76
babelOptions . plugins = [
77
77
// stage 0
78
78
require ( "@babel/plugin-proposal-function-bind" ) . default ,
79
79
80
80
// stage 1
81
81
require ( "@babel/plugin-proposal-export-default-from" ) . default ,
82
82
require ( "@babel/plugin-proposal-logical-assignment-operators" ) . default ,
83
- [ require ( "@babel/plugin-proposal-optional-chaining" ) . default , { loose : false } ] ,
84
- [ require ( "@babel/plugin-proposal-pipeline-operator" ) . default , { proposal : "minimal" } ] ,
85
- [ require ( "@babel/plugin-proposal-nullish-coalescing-operator" ) . default , { loose : false } ] ,
83
+ [ require ( "@babel/plugin-proposal-optional-chaining" ) . default , { loose : false } ] ,
84
+ [ require ( "@babel/plugin-proposal-pipeline-operator" ) . default , { proposal : "minimal" } ] ,
85
+ [ require ( "@babel/plugin-proposal-nullish-coalescing-operator" ) . default , { loose : false } ] ,
86
86
require ( "@babel/plugin-proposal-do-expressions" ) . default ,
87
87
88
88
// stage 2
89
- [ require ( "@babel/plugin-proposal-decorators" ) . default , { legacy : true } ] ,
89
+ [ require ( "@babel/plugin-proposal-decorators" ) . default , { legacy : true } ] ,
90
90
require ( "@babel/plugin-proposal-function-sent" ) . default ,
91
91
require ( "@babel/plugin-proposal-export-namespace-from" ) . default ,
92
92
require ( "@babel/plugin-proposal-numeric-separator" ) . default ,
@@ -95,9 +95,9 @@ function testOnlyBabel(babel: any, babelOptions: any, nodeVersion: string): any
95
95
// stage 3
96
96
require ( "@babel/plugin-syntax-dynamic-import" ) . default ,
97
97
require ( "@babel/plugin-syntax-import-meta" ) . default ,
98
- [ require ( "@babel/plugin-proposal-class-properties" ) . default , { loose : false } ] ,
98
+ [ require ( "@babel/plugin-proposal-class-properties" ) . default , { loose : false } ] ,
99
99
require ( "@babel/plugin-proposal-json-strings" ) . default ,
100
100
]
101
101
babelOptions . babelrc = false
102
102
return babel
103
- }
103
+ }
0 commit comments