Skip to content

Commit

Permalink
feat: add yaml dependency (#274)
Browse files Browse the repository at this point in the history
* feat: add yaml dependency

* docs: add yaml package entry to readme

* ref: rename YAML package and add declaration

Co-authored-by: Anton Medvedev <antonmedv@google.com>
  • Loading branch information
henrycunh and antonmedv committed Jan 24, 2022
1 parent 1ad81de commit 0109e06
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ The [chalk](https://www.npmjs.com/package/chalk) package.
console.log(chalk.blue('Hello world!'))
```

#### `yaml` package

The [yaml](https://www.npmjs.com/package/yaml) package.

```js
console.log(YAML.parse('foo: bar').foo)
```

#### `fs` package

The [fs-extra](https://www.npmjs.com/package/fs-extra) package.
Expand Down
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as _globby from 'globby'
import * as _os from 'os'
import * as _path from 'path'
import * as _chalk from 'chalk'
import * as _yaml from 'yaml'
import _fetch from 'node-fetch'
import {ParsedArgs} from 'minimist'

Expand Down Expand Up @@ -63,6 +64,7 @@ export const argv: ParsedArgs
export const cd: cd
export const chalk: typeof _chalk
export const fetch: typeof _fetch
export const YAML: typeof _yaml
export const fs: typeof _fs
export const glob: typeof _globby.globby & typeof _globby
export const globby: typeof _globby.globby & typeof _globby
Expand Down
4 changes: 3 additions & 1 deletion index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import {createInterface} from 'readline'
import {default as nodeFetch} from 'node-fetch'
import which from 'which'
import chalk from 'chalk'
import YAML from 'yaml'
import minimist from 'minimist'
import psTreeModule from 'ps-tree'

export {chalk, fs, os, path}
export {chalk, fs, os, path, YAML}
export const sleep = promisify(setTimeout)
export const argv = minimist(process.argv.slice(2))
export const globby = Object.assign(function globby(...args) {
Expand All @@ -49,6 +50,7 @@ export function registerGlobals() {
path,
question,
sleep,
YAML,
})
}

Expand Down
16 changes: 15 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"minimist": "^1.2.5",
"node-fetch": "^2.6.1",
"ps-tree": "^1.2.0",
"which": "^2.0.2"
"which": "^2.0.2",
"yaml": "^1.10.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^20.0.0",
Expand Down
12 changes: 12 additions & 0 deletions test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,16 @@ import {strict as assert} from 'assert'
console.log(chalk.black.bgYellowBright(` ${name} version is ${version} `))
}

{ // yaml parsing and stringifying is available
assert(typeof YAML === 'object')
assert(typeof YAML.parse === 'function')
assert(typeof YAML.stringify === 'function')
console.log(chalk.greenBright('yaml parsing and stringifying is available'))
}

{ // yaml parsing and stringifying works
assert.deepEqual(YAML.parse(YAML.stringify({foo: 'bar'})), {foo: 'bar'})
console.log(chalk.greenBright('yaml parsing and stringifying works'))
}

console.log(chalk.greenBright(' 🍺 Success!'))

0 comments on commit 0109e06

Please sign in to comment.