Skip to content

Commit

Permalink
Merge branch 'main' into use-test-config-for-watch
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowspawn committed Jan 14, 2024
2 parents 2b93ac5 + 0c95f9c commit a143679
Show file tree
Hide file tree
Showing 45 changed files with 231 additions and 174 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/ci.yaml
Expand Up @@ -13,13 +13,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [12, 14, 16]
node: [16, 18, 20]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install -g npm@7
- run: npm install -g npm@8
- run: node --version
- run: npm install --engine-strict
- run: npm test
Expand All @@ -29,21 +29,21 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm install -g npm@7
node-version: 20
- run: npm install -g npm@8
- run: npm install
- run: npm test
esm:
runs-on: ubuntu-latest
strategy:
matrix:
node: [14]
node: [20]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install -g npm@7
- run: npm install -g npm@8
- run: node --version
- run: npm install --engine-strict
- run: npm run test:esm
Expand All @@ -53,8 +53,8 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
- run: npm install -g npm@7
node-version: 20
- run: npm install -g npm@8
- run: npm install
- run: npm run compile
- uses: denoland/setup-deno@v1
Expand All @@ -69,8 +69,8 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 15
- run: npm install -g npm@7
node-version: 20
- run: npm install -g npm@8
- run: npm install
- run: npm test
- run: npm run coverage
5 changes: 2 additions & 3 deletions .github/workflows/release-please.yml
Expand Up @@ -12,16 +12,15 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
- uses: google-github-actions/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
package-name: yargs
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
node-version: 20
- run: npm install npm@latest -g
- run: npm install
- run: npm run compile
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -61,7 +61,7 @@ npm i yargs@next
#!/usr/bin/env node
const yargs = require('yargs/yargs')
const { hideBin } = require('yargs/helpers')
const argv = yargs(hideBin(process.argv)).argv
const argv = yargs(hideBin(process.argv)).parse()

if (argv.ships > 3 && argv.distance < 53.5) {
console.log('Plunder more riffiwobbles!')
Expand Down
32 changes: 16 additions & 16 deletions docs/advanced.md
Expand Up @@ -18,7 +18,7 @@ const argv = require('yargs/yargs')(process.argv.slice(2))
.command('$0', 'the default command', () => {}, (argv) => {
console.log('this command will be run by default')
})
.argv
.parse()
```

The command defined above will be executed if the program
Expand All @@ -31,7 +31,7 @@ const argv = require('yargs/yargs')(process.argv.slice(2))
.command(['serve', '$0'], 'the serve command', () => {}, (argv) => {
console.log('this command will be run by default')
})
.argv
.parse()
```

The command defined above will be executed if the program
Expand All @@ -47,7 +47,7 @@ take the form `[bar]`. The parsed positional arguments will be populated in
```js
yargs.command('get <source> [proxy]', 'make a get HTTP request')
.help()
.argv
.parse()
```

#### Positional Argument Aliases
Expand All @@ -59,7 +59,7 @@ an email as the first argument:
```js
yargs.command('get <username|email> [password]', 'fetch a user by username or email.')
.help()
.argv
.parse()
```

In this way, both `argv.username` and `argv.email` would be populated with the
Expand All @@ -73,7 +73,7 @@ values, by using the `..` operator:
```js
yargs.command('download <url> [files..]', 'download several files')
.help()
.argv
.parse()
```

#### Describing Positional Arguments
Expand All @@ -91,7 +91,7 @@ yargs.command('get <source> [proxy]', 'make a get HTTP request', (yargs) => {
})
})
.help()
.argv
.parse()
```

### Command Execution
Expand Down Expand Up @@ -140,7 +140,7 @@ require('yargs/yargs')(process.argv.slice(2))
.demandCommand()
.help()
.wrap(72)
.argv
.parse()
```

```
Expand Down Expand Up @@ -196,15 +196,15 @@ You then register the module like so:
```js
yargs.command(require('my-module'))
.help()
.argv
.parse()
```

Or if the module does not export `command` and `describe` (or if you just want to override them):

```js
yargs.command('get <source> [proxy]', 'make a get HTTP request', require('my-module'))
.help()
.argv
.parse()
```

#### Testing a Command Module
Expand Down Expand Up @@ -311,7 +311,7 @@ require('yargs/yargs')(process.argv.slice(2))
.commandDir('cmds')
.demandCommand()
.help()
.argv
.parse()
```

cmds/init.js:
Expand Down Expand Up @@ -391,7 +391,7 @@ import { commands } from './cmds/index.mjs';

yargs(hideBin(process.argv))
.command(commands)
.argv;
.parse();
```

<a name="configuration"></a>
Expand Down Expand Up @@ -419,7 +419,7 @@ const configPath = findUp.sync(['.myapprc', '.myapprc.json'])
const config = configPath ? JSON.parse(fs.readFileSync(configPath)) : {}
const argv = require('yargs/yargs')(process.argv.slice(2))
.config(config)
.argv
.parse()
```

### Providing Configuration in Your package.json
Expand Down Expand Up @@ -447,7 +447,7 @@ method:
```js
const argv = require('yargs/yargs')(process.argv.slice(2))
.pkgConf('nyc')
.argv
.parse()
```

### Creating a Plugin Architecture
Expand Down Expand Up @@ -552,13 +552,13 @@ var argv = require('yargs/yargs')(process.argv.slice(2))
},
[normalizeCredentials]
)
.argv;
.parse();
```

## Using Yargs with Async/await

If you use async middleware or async builders/handlers for commands, `yargs.parse` and
`yargs.argv` will return a `Promise`. When you `await` this promise the
If you use async middleware or async builders/handlers for commands, `yargs.parse()`
will return a `Promise`. When you `await` this promise the
parsed arguments object will be returned after the handler completes:

```js
Expand Down

0 comments on commit a143679

Please sign in to comment.