Skip to content

Commit b18525f

Browse files
authored
Merge pull request #20 from ernilambar/add-args
Add args
2 parents 422cdac + ae3b9aa commit b18525f

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ Run from your project root (the directory that contains `package.json` with your
1818
npx wp-deployer
1919
```
2020

21-
Show CLI help or version:
21+
CLI sub-commands:
2222

2323
```sh
2424
npx wp-deployer --help
2525
npx wp-deployer --version
26+
npx wp-deployer --assets
2627
```
2728

29+
Use `--assets` when you only want to push the assets directory (e.g. screenshots, banner) to WordPress.org and skip trunk and tag deployment.
30+
2831
Or add a script to `package.json` and run it:
2932

3033
```sh

index.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const exec = promisify(execCb)
2828
const __dirname = path.dirname(fileURLToPath(import.meta.url))
2929

3030
const argv = minimist(process.argv.slice(2), {
31-
boolean: ['help', 'version'],
31+
boolean: ['help', 'version', 'assets'],
3232
alias: { h: 'help', v: 'version' }
3333
})
3434

@@ -38,8 +38,9 @@ function printHelp () {
3838
Deploy a WordPress plugin or theme to WordPress.org SVN using wpDeployer in package.json.
3939
4040
Options:
41-
--help, -h Show this message
42-
--version, -v Print wp-deployer version
41+
--help, -h Show this message
42+
--version, -v Print wp-deployer version
43+
--assets Deploy only the assets directory (plugin only; skips trunk and tag)
4344
`)
4445
}
4546

@@ -72,7 +73,7 @@ process.on('SIGINT', () => {
7273
const wpDeployer = async () => {
7374
console.log(chalk.cyan('Processing...'))
7475

75-
const { settings, error, errorMessage } = resolveSettings(pkg)
76+
let { settings, error, errorMessage } = resolveSettings(pkg)
7677
if (error === 'invalid_slug') {
7778
console.error(chalk.red(`Invalid slug: ${errorMessage}`))
7879
return EXIT_CONFIG
@@ -106,6 +107,19 @@ const wpDeployer = async () => {
106107
return EXIT_CONFIG
107108
}
108109

110+
if (argv.assets) {
111+
if (settings.repoType !== 'plugin') {
112+
console.error(chalk.red('--assets is only supported for plugins.'))
113+
return EXIT_CONFIG
114+
}
115+
settings = {
116+
...settings,
117+
deployTrunk: false,
118+
deployTag: false,
119+
deployAssets: true
120+
}
121+
}
122+
109123
try {
110124
runPreflightSync(settings, { fs, awk })
111125
} catch (e) {

test/cli-flags.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@ describe('CLI flags', () => {
3535
assert.strictEqual(r.status, 0, r.stderr)
3636
assert.match(r.stdout, /Usage:\s*wp-deployer/i)
3737
})
38+
39+
it('--help documents --assets', () => {
40+
const r = spawnSync(process.execPath, [indexJs, '--help'], { encoding: 'utf8' })
41+
assert.strictEqual(r.status, 0, r.stderr)
42+
assert.match(r.stdout, /--assets\b/)
43+
})
3844
})

0 commit comments

Comments
 (0)