@penskemediacorp/twig-to-php-parser 1.66.4 → 1.69.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -11,7 +11,7 @@ const config = getAppConfiguration( 'parser' );
11
11
  * package README for supported configuration.
12
12
  */
13
13
 
14
- function twigToPhpParser( config = {} ) {
14
+ function twigToPhpParser( thisConfig = {} ) {
15
15
  // TODO: We need some kind of wrapper here for config...or better:
16
16
  // move this to pmc-plugins/pmc-larva and scrap this awkward JS
17
17
  // execPhp wrapper situation, and use Larva\Config for this config.
@@ -19,33 +19,36 @@ function twigToPhpParser( config = {} ) {
19
19
  let phpDir = path.join( process.cwd(), '../template-parts/patterns' );
20
20
  let isUsingPlugin = false;
21
21
 
22
- if ( 'undefined' !== typeof config.twigDir ) {
23
- if ( config.twigDir.startsWith( '.' ) ) {
24
- twigDir = path.join( process.cwd(), config.twigDir );
22
+ if ( 'undefined' !== typeof thisConfig.twigDir ) {
23
+ if ( thisConfig.twigDir.startsWith( '.' ) ) {
24
+ twigDir = path.join( process.cwd(), thisConfig.twigDir );
25
25
  } else {
26
- twigDir = config.twigDir;
26
+ twigDir = thisConfig.twigDir;
27
27
  }
28
- } else if ( 'undefined' !== typeof config.relativeSrcOverride ) {
29
- if ( config.relativeSrcOverride.startsWith( '/' ) ) {
30
- twigDir = config.relativeSrcOverride;
28
+ } else if ( 'undefined' !== typeof thisConfig.relativeSrcOverride ) {
29
+ if ( thisConfig.relativeSrcOverride.startsWith( '/' ) ) {
30
+ twigDir = thisConfig.relativeSrcOverride;
31
31
  } else {
32
- twigDir = path.join( process.cwd(), config.relativeSrcOverride );
32
+ twigDir = path.join(
33
+ process.cwd(),
34
+ thisConfig.relativeSrcOverride
35
+ );
33
36
  }
34
37
  }
35
38
 
36
- if ( 'undefined' !== typeof config.isUsingPlugin ) {
37
- isUsingPlugin = config.isUsingPlugin;
39
+ if ( 'undefined' !== typeof thisConfig.isUsingPlugin ) {
40
+ isUsingPlugin = thisConfig.isUsingPlugin;
38
41
  }
39
42
 
40
- if ( 'undefined' !== typeof config.phpDir ) {
41
- phpDir = config.phpDir;
43
+ if ( 'undefined' !== typeof thisConfig.phpDir ) {
44
+ phpDir = thisConfig.phpDir;
42
45
  }
43
46
 
44
47
  return new Promise( ( resolve, reject ) => {
45
48
  execPhp(
46
49
  path.resolve( __dirname, './lib/twig-to-php-parser.php' ),
47
- config.phpBinaryPath,
48
- function ( error, php, output ) {
50
+ thisConfig.phpBinaryPath,
51
+ function ( error, php ) {
49
52
  if ( error ) {
50
53
  reject( error );
51
54
  }
@@ -54,9 +57,9 @@ function twigToPhpParser( config = {} ) {
54
57
  twigDir,
55
58
  phpDir,
56
59
  isUsingPlugin,
57
- function ( error, result, output, printed ) {
58
- if ( error ) {
59
- reject( error );
60
+ function ( thisError, result ) {
61
+ if ( thisError ) {
62
+ reject( thisError );
60
63
  }
61
64
 
62
65
  resolve( result );
@@ -77,7 +80,7 @@ function parseIncludePath(
77
80
  execPhp(
78
81
  path.resolve( __dirname, './lib/twig-to-php-parser.php' ),
79
82
  config.phpBinaryPath,
80
- function ( error, php, output ) {
83
+ function ( error, php ) {
81
84
  if ( error ) {
82
85
  reject( error );
83
86
  }
@@ -87,9 +90,9 @@ function parseIncludePath(
87
90
  patternName,
88
91
  dataName,
89
92
  isUsingPlugin,
90
- function ( error, result, output, printed ) {
91
- if ( error ) {
92
- reject( error );
93
+ function ( thisError, result ) {
94
+ if ( thisError ) {
95
+ reject( thisError );
93
96
  }
94
97
 
95
98
  resolve( result );
@@ -105,7 +108,7 @@ function parseSvgPath( twigSvgIncludeStr, svgName, isUsingPlugin = false ) {
105
108
  execPhp(
106
109
  path.resolve( __dirname, './lib/twig-to-php-parser.php' ),
107
110
  config.phpBinaryPath,
108
- function ( error, php, output ) {
111
+ function ( error, php ) {
109
112
  if ( error ) {
110
113
  reject( error );
111
114
  }
@@ -114,9 +117,9 @@ function parseSvgPath( twigSvgIncludeStr, svgName, isUsingPlugin = false ) {
114
117
  twigSvgIncludeStr,
115
118
  svgName,
116
119
  isUsingPlugin,
117
- function ( error, result, output, printed ) {
118
- if ( error ) {
119
- reject( error );
120
+ function ( thisError, result ) {
121
+ if ( thisError ) {
122
+ reject( thisError );
120
123
  }
121
124
 
122
125
  resolve( result );
@@ -132,16 +135,16 @@ function parseWpAction( twigMarkup ) {
132
135
  execPhp(
133
136
  path.resolve( __dirname, './lib/twig-to-php-parser.php' ),
134
137
  config.phpBinaryPath,
135
- function ( error, php, output ) {
138
+ function ( error, php ) {
136
139
  if ( error ) {
137
140
  reject( error );
138
141
  }
139
142
 
140
143
  php.parse_wp_action(
141
144
  twigMarkup,
142
- function ( error, result, output, printed ) {
143
- if ( error ) {
144
- reject( error );
145
+ function ( thisError, result ) {
146
+ if ( thisError ) {
147
+ reject( thisError );
145
148
  }
146
149
 
147
150
  resolve( result );
@@ -161,12 +164,15 @@ module.exports = {
161
164
  },
162
165
  run: () => {
163
166
  twigToPhpParser( config )
167
+ // eslint-disable-next-line no-console
164
168
  .catch( ( e ) => console.log( e ) ) // PHP errors
165
- .then( ( result ) =>
169
+ .then( () =>
170
+ // eslint-disable-next-line no-console
166
171
  console.log(
167
172
  chalk.green( 'Completed parsing Twig templates to PHP.' )
168
173
  )
169
174
  )
175
+ // eslint-disable-next-line no-console
170
176
  .catch( ( e ) => console.log( e ) );
171
177
  },
172
178
  };
package/lib/getConfig.js CHANGED
@@ -37,6 +37,7 @@ module.exports = function getAppConfiguration( key ) {
37
37
 
38
38
  return config;
39
39
  } catch ( error ) {
40
+ // eslint-disable-next-line no-console
40
41
  console.error(
41
42
  chalk.red(
42
43
  chalk.bold(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@penskemediacorp/twig-to-php-parser",
3
- "version": "1.66.4",
3
+ "version": "1.69.0",
4
4
  "description": "> TODO: description",
5
5
  "author": "laras126 <laras126@gmail.com>",
6
6
  "homepage": "https://github.com/penske-media-corp/pmc-larva#readme",
@@ -26,5 +26,5 @@
26
26
  "chalk": "^4",
27
27
  "exec-php": "^0"
28
28
  },
29
- "gitHead": "adf0f680fa45f26d69992517ee9b2ebe611f8aad"
29
+ "gitHead": "9655cabc42a4d705c189ea9b65e6d34788a809e9"
30
30
  }