new-s-block 1.1.0 → 1.1.1
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/bin/cli.js +14 -0
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -164,6 +164,9 @@ async function main() {
|
|
|
164
164
|
const scssFile = subFolder
|
|
165
165
|
? path.join(cwd, 'assets', 'sass', 'blocks', subFolder, blockName + '.scss')
|
|
166
166
|
: path.join(cwd, 'assets', 'sass', 'blocks', blockName + '.scss');
|
|
167
|
+
const jsFile = subFolder
|
|
168
|
+
? path.join(cwd, 'assets', 'js', 'blocks', subFolder, blockName + '.js')
|
|
169
|
+
: path.join(cwd, 'assets', 'js', 'blocks', blockName + '.js');
|
|
167
170
|
|
|
168
171
|
if (fs.existsSync(blockDir)) {
|
|
169
172
|
console.error('\n\u274C Block folder already exists: ' + path.relative(cwd, blockDir) + '\n');
|
|
@@ -226,6 +229,12 @@ async function main() {
|
|
|
226
229
|
|
|
227
230
|
writeFile(scssFile, scssContent);
|
|
228
231
|
|
|
232
|
+
// ── block-name.js (optional) ─────────────────────────────────────────────
|
|
233
|
+
|
|
234
|
+
if (includeJs === 'y') {
|
|
235
|
+
writeFile(jsFile, '');
|
|
236
|
+
}
|
|
237
|
+
|
|
229
238
|
// ── Summary ──────────────────────────────────────────────────────────────
|
|
230
239
|
|
|
231
240
|
var cyan = '\x1b[36m';
|
|
@@ -238,6 +247,11 @@ async function main() {
|
|
|
238
247
|
var sassDisplay = subFolder ? 'assets/sass/blocks/' + subFolder + '/' : 'assets/sass/blocks/';
|
|
239
248
|
console.log(' \uD83D\uDCC1 ' + sassDisplay);
|
|
240
249
|
console.log(' \u2514\u2500\u2500 ' + blockName + '.scss');
|
|
250
|
+
if (includeJs === 'y') {
|
|
251
|
+
var jsDisplay = subFolder ? 'assets/js/blocks/' + subFolder + '/' : 'assets/js/blocks/';
|
|
252
|
+
console.log(' \uD83D\uDCC1 ' + jsDisplay);
|
|
253
|
+
console.log(' \u2514\u2500\u2500 ' + blockName + '.js');
|
|
254
|
+
}
|
|
241
255
|
console.log('');
|
|
242
256
|
console.log(" Don't forget to add " + cyan + "register_block_type( __DIR__ . '/../blocks/" + blockRelPath + "' );" + reset + " in 'includes/template-functions.php'");
|
|
243
257
|
console.log('');
|