diff --git a/bin/init.js b/bin/init.js index a62a69b..15ff6f7 100755 --- a/bin/init.js +++ b/bin/init.js @@ -352,7 +352,6 @@ const runThemeCleanup = () => { '.git', '.github', 'bin', - 'languages', ]; deleteDirs.forEach((dir) => { diff --git a/bin/phpcbf.js b/bin/phpcbf.js new file mode 100644 index 0000000..b974ed2 --- /dev/null +++ b/bin/phpcbf.js @@ -0,0 +1,30 @@ +const { spawn } = require('cross-spawn'); + +// Get the command-line arguments excluding the first two (node and script.js) +const args = process.argv.slice(2); + +// Define the main command you want to run. +const command = './vendor/bin/phpcbf'; + +// Combine the command and arguments. +const fullCommand = [command, ...args]; + +// Spawn the process. +const child = spawn(fullCommand[0], fullCommand.slice(1)); + +// Handle process events. +child.stdout.on('data', (data) => { + console.log(`stdout: ${data}`); +}); + +child.stderr.on('data', (data) => { + console.error(`stderr: ${data}`); +}); + +child.on('error', (error) => { + console.error(`Error: ${error.message}`); +}); + +child.on('close', (code) => { + console.log(`Child process exited with code ${code}`); +}); diff --git a/package.json b/package.json index c567c21..896efbe 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,15 @@ "license": "MIT", "private": true, "scripts": { - "prod": "NODE_ENV=production webpack --progress && npm run pot", + "prod": "cross-env NODE_ENV=production webpack --progress && npm run pot", "dev": "webpack --watch --progress", "clean": "rm -rf assets/build/*", - "init": "./bin/init.js && npm run pot", + "init": "node ./bin/init.js && npm run pot", "lint:css": "stylelint assets/src/sass/**/*.scss --syntax scss", + "lint:js:fix": "eslint assets/src/js/ --fix", "lint:js": "eslint assets/src/js/", - "lint:php": "./vendor/bin/phpcs", - "lint:php:fix": "./bin/phpcbf.sh", + "lint:php": "php ./vendor/bin/phpcs", + "lint:php:fix": "node ./bin/phpcbf.js", "lint:staged": "lint-staged", "pot": "wp-pot --src './**/*.php' --dest-file './languages/blank-theme.pot' --domain 'blank-theme' --package 'Blank Theme' ", "precommit": "npm-run-all lint:* pot", @@ -24,12 +25,14 @@ "webfontloader": "^1.6.28" }, "devDependencies": { + "cross-spawn": "^7.0.3", "@wordpress/babel-preset-default": "^6.2.0", "@wordpress/browserslist-config": "^4.0.1", "@wordpress/dependency-extraction-webpack-plugin": "^3.1.4", "@wordpress/eslint-plugin": "^9.0.6", "@wordpress/stylelint-config": "^19.0.5", "babel-loader": "^8.2.2", + "cross-env": "^7.0.3", "css-loader": "^5.2.6", "eslint": "^7.27.0", "eslint-webpack-plugin": "^2.5.4",