Skip to content

Instantly share code, notes, and snippets.

korzio

Block or report user

Report or block korzio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View async generators.js
async function get(n) {
return new Promise(r => setTimeout(() => r(n), n * 100))
}
async function* asyncGenerator(arr) {
var anyResolve
var waiting = () => new Promise((resolve) => {
anyResolve = resolve
})
View oclif add command.ts
npx oclif help
npx oclif command-help
npx oclif command add
my-oclif add
@korzio
korzio / JS Planet Alex Korzhikov
Created Jun 2, 2019
JS Planet Alex Korzhikov
View JS Planet Alex Korzhikov
_ ____ ____ _ _
| / ___| | _ \| | __ _ _ __ ___| |_
_ | \___ \ | |_) | |/ _` | '_ \ / _ \ __|
| |_| |___) | | __/| | (_| | | | | __/ |_
\___/|____/ |_| |_|\__,_|_| |_|\___|\__|
_ _ _ __ _ _ _
/ \ | | _____ __ | |/ /___ _ __ ___| |__ (_) | _______ __
/ _ \ | |/ _ \ \/ / | ' // _ \| '__|_ / '_ \| | |/ / _ \ \ / /
/ ___ \| | __/> < | . \ (_) | | / /| | | | | < (_) \ V /
/_/ \_\_|\___/_/\_\ |_|\_\___/|_| /___|_| |_|_|_|\_\___/ \_/
View commit.ts
import {Hook} from '@oclif/config'
import * as nodegit from 'nodegit'
import * as path from 'path'
const hook: Hook<'commit'> = async function ({id, file: fileName}) {
const directoryName = process.cwd()
const repo = await nodegit.Repository.open(path.resolve(directoryName, '.git'))
const index = await repo.refreshIndex()
await index.addByPath(fileName)
View oclif hook generate.sh
oclif hook commit --event=commit
cat src/hooks/commit/commit.ts
import {Hook} from '@oclif/config'
const hook: Hook<'commit'> = async function (opts) {
process.stdout.write(`example hook running ${opts.id}\n`)
}
export default hook
View oclif package.json
"oclif": {
"bin": "web",
"commands": "./lib/commands",
"plugins": [
"@oclif/plugin-help"
],
"scope": "ing-web-cli",
"hooks": {
"init": "./src/hooks/init/myhook"
}
View add.ts
import {Command, flags} from '@oclif/command'
import {existsSync, writeFileSync} from 'fs'
export default class Add extends Command {
static description = 'add new note'
static flags = {
help: flags.help({char: 'h'}),
}
View generate my oclif package.sh
mkdir my-oclif # create new source folder
cd my-oclif # locate to source folder
npm init -f # init empty npm package
npx oclif # ensure oclif can help
npx oclif multi # generate or scaffold multi command oclif application
View oclif generate output.sh
➜ my-oclif git:(master) ✗ npx oclif multi
npx: installed 442 in 9.042s
_-----_ ╭──────────────────────────╮
| | │ Time to build a │
|--(o)--| │ multi-command CLI with │
`---------´ │ oclif! Version: 1.13.1 │
( _´U`_ ) ╰──────────────────────────╯
/___A___\ /
| ~ |
View oclif generated folders structure.sh
tree . -L 1
.
├── README.md
├── bin
├── node_modules
├── package-lock.json
├── package.json
├── src
├── test
├── tsconfig.json
You can’t perform that action at this time.