sdc-build-wp 3.0.1 → 3.0.3
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/lib/blocks.js +12 -4
- package/package.json +1 -1
package/lib/blocks.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
1
2
|
import path from 'path';
|
|
2
3
|
import project from '../lib/project.js';
|
|
3
4
|
import log from './logging.js';
|
|
@@ -10,9 +11,12 @@ function cmd(...command) {
|
|
|
10
11
|
shell: true
|
|
11
12
|
});
|
|
12
13
|
return new Promise((resolveFunc) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
p.stdout.on('data', (x) => {
|
|
15
|
+
if (x.toString().includes('Error:')) {
|
|
16
|
+
process.stdout.write(x.toString());
|
|
17
|
+
log('error', `Failed building blocks - See above error.`);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
16
20
|
p.stderr.on('data', (x) => {
|
|
17
21
|
process.stderr.write(x.toString());
|
|
18
22
|
log('error', `Failed building blocks - See above error.`);
|
|
@@ -43,7 +47,11 @@ const buildBlock = async (entry) => {
|
|
|
43
47
|
return false;
|
|
44
48
|
}
|
|
45
49
|
let timerStart = Date.now();
|
|
46
|
-
|
|
50
|
+
let cmds = [`build`];
|
|
51
|
+
for (var file of (await fs.readdir(`${entry}/src`)).filter(file => path.extname(file) == '.js')) {
|
|
52
|
+
cmds.push(`src/${file}`);
|
|
53
|
+
}
|
|
54
|
+
await cmd(`cd ${entry} && ${project.path}/node_modules/@wordpress/scripts/bin/wp-scripts.js`, ...cmds);
|
|
47
55
|
log('success', `Built ${entry.replace(project.path, '')} in ${Date.now() - timerStart}ms`);
|
|
48
56
|
};
|
|
49
57
|
|