sdc-build-wp 5.6.13 → 5.6.14
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/.phpcs.xml +0 -6
- package/lib/components/php.js +23 -11
- package/package.json +1 -1
package/.phpcs.xml
CHANGED
|
@@ -13,12 +13,6 @@
|
|
|
13
13
|
</rule>
|
|
14
14
|
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
|
|
15
15
|
<rule ref="Generic.WhiteSpace.LanguageConstructSpacing"/>
|
|
16
|
-
<rule ref="Generic.WhiteSpace.ScopeIndent">
|
|
17
|
-
<properties>
|
|
18
|
-
<property name="exact" value="true" />
|
|
19
|
-
<property name="indent" value="2"/>
|
|
20
|
-
</properties>
|
|
21
|
-
</rule>
|
|
22
16
|
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing"/>
|
|
23
17
|
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
|
|
24
18
|
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
|
package/lib/components/php.js
CHANGED
|
@@ -83,21 +83,33 @@ export default class PHPComponent extends BaseComponent {
|
|
|
83
83
|
} catch (error) {
|
|
84
84
|
// Filter out Time: and Memory: lines from error output
|
|
85
85
|
const filterLines = str => str
|
|
86
|
-
? str.split('\n').filter(line => !line.trim().startsWith('Time:') && !line.trim().startsWith('Memory:')).join('\n')
|
|
86
|
+
? str.split('\n').filter(line => !line.trim().startsWith('Time:') && !line.trim().startsWith('Memory:')).join('\n').trim()
|
|
87
87
|
: str;
|
|
88
|
-
|
|
88
|
+
const filteredStderr = filterLines(error.stderr);
|
|
89
|
+
const filteredStdout = filterLines(error.stdout);
|
|
90
|
+
if (filteredStderr && error.stderr.includes('No fixable errors were found')) {
|
|
89
91
|
// No fixable errors were found
|
|
90
92
|
} else if (
|
|
91
|
-
(
|
|
92
|
-
(
|
|
93
|
-
filterLines(error.stdout)?.length &&
|
|
94
|
-
(
|
|
95
|
-
error.stdout.startsWith('ERROR:') ||
|
|
96
|
-
error.stdout.includes('FAILED TO FIX')
|
|
97
|
-
)
|
|
98
|
-
)
|
|
93
|
+
(filteredStderr && !error.stderr.trim().startsWith('Time:')) ||
|
|
94
|
+
(filteredStdout && (error.stdout.startsWith('ERROR:') || error.stdout.includes('FAILED TO FIX')))
|
|
99
95
|
) {
|
|
100
|
-
|
|
96
|
+
let detail = filteredStderr || filteredStdout;
|
|
97
|
+
// If phpcbf failed to fix remaining errors, run phpcs to surface the actual violations
|
|
98
|
+
if (error.stdout.includes('FAILED TO FIX') && options.lintType === 'fix') {
|
|
99
|
+
try {
|
|
100
|
+
const phpcsCmd = [`php`, `-d`, `memory_limit=2G`, `vendor/bin/phpcs`, phpFiles].join(' ');
|
|
101
|
+
const execPromise2 = promisify(exec);
|
|
102
|
+
await execPromise2(phpcsCmd, {
|
|
103
|
+
cwd: this.path.resolve(this.path.dirname(fileURLToPath(import.meta.url)), '../../')
|
|
104
|
+
});
|
|
105
|
+
} catch (phpcsError) {
|
|
106
|
+
const phpcsDetail = filterLines(phpcsError.stdout) || filterLines(phpcsError.stderr);
|
|
107
|
+
if (phpcsDetail) {
|
|
108
|
+
detail = phpcsDetail;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
this.log(null, detail);
|
|
101
113
|
this.log('error', `Failed linting ${entryLabel.replace(this.project.path, '')} - See above error.`);
|
|
102
114
|
return false;
|
|
103
115
|
}
|