Skip to content

Instantly share code, notes, and snippets.

View jdx's full-sized avatar
⚜️
mise-en-place!

jdx

⚜️
mise-en-place!
View GitHub Profile
import {Command} from '@oclif/command'
import axios from 'axios'
export default class Stars extends Command {
static description = 'show the github stars on a repository'
static args = [{name: 'repository', required: true}]
async run() {
const {args} = this.parse(Stars)
const {data: stargazers} = await axios.get(`https://api.github.com/repos/${args.repository}/stargazers`)
for (let s of stargazers) {
@jdx
jdx / test.ts
Last active March 1, 2018 20:56
parse override
protected parse<F, A extends {[name: string]: any}>(options: Parser.Input<F>, argv = this.argv): Parser.Output<F, A> {
const {flags, args, strict} = options
return require('@oclif/parser').parse(argv, {context: this, flags, args, strict})
}
const fs = require('fs-extra');
const path = require('path');
const debug = require('debug')('rwlockfile');
const mkdir = require('mkdirp');
let locks = {};
let readers = {};
async function pidActive(pid) {
if (!pid || isNaN(pid)) return false;
@jdx
jdx / command.js
Last active October 31, 2017 22:39
windows lockfile contention repro
const rwlockfile = require('./src/rwlockfile')
rwlockfile.read('foo')
console.log('unread foo in 10s')
setTimeout(() => {
console.log('unreading foo')
rwlockfile.unread('foo')
}, 10000)
// ./package.json
{
'cli-engine': {
events: {
preRun: './lib/events/pre_run.js'
}
}
}
// ./lib/events/before_run.js
@jdx
jdx / flag.js
Created July 10, 2017 20:39
required resuable flag
// flag.js
import { merge, type Flag } from 'cli-engine-command/lib/flags'
type Options = $Shape<Flag<boolean>>
export default function ResetFlag (options: Options = {}, env: typeof process.env = process.env): Flag<string> {
const defaultOptions: Options = {
char: 'r',
parse: (input, cmd) => {
if (options.required) throw new Error('you should have set --reset')
}
Arguments:
/usr/local/bin/node /usr/local/bin/yarn
PATH:
./bin:./node_modules/.bin:/usr/local/opt/go/libexec/bin:/Users/dickeyxxx/bin:/usr/local/bin:/usr/local/sbin:./bin:./node_modules/.bin:/usr/local/opt/go/libexec/bin:/Users/dickeyxxx/bin:/usr/local/bin:/usr/local/sbin:./bin:./node_modules/.bin:/usr/local/opt/go/libexec/bin:/Users/dickeyxxx/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/Users/dickeyxxx/.config/yarn/global/node_modules/.bin:/Users/dickeyxxx/.cargo/bin:/usr/local/bin:/Users/dickeyxxx/.config/yarn/global/node_modules/.bin:/Users/dickeyxxx/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/usr/local/bin:/Users/dickeyxxx/.config/yarn/global/node_modules/.bin:/Users/dickeyxxx/.cargo/bin
Yarn version:
0.27.5
Node version:
Arguments:
/usr/local/bin/node /usr/local/bin/yarn add file:./test/heroku-debug/5.0.3
PATH:
./bin:./node_modules/.bin:/usr/local/opt/go/libexec/bin:/Users/dickeyxxx/bin:/usr/local/bin:/usr/local/sbin:./bin:./node_modules/.bin:/usr/local/opt/go/libexec/bin:/Users/dickeyxxx/bin:/usr/local/bin:/usr/local/sbin:./bin:./node_modules/.bin:/usr/local/opt/go/libexec/bin:/Users/dickeyxxx/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/Users/dickeyxxx/.config/yarn/global/node_modules/.bin:/Users/dickeyxxx/.cargo/bin:/usr/local/bin:/Users/dickeyxxx/.config/yarn/global/node_modules/.bin:/Users/dickeyxxx/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/usr/local/bin:/Users/dickeyxxx/.config/yarn/global/node_modules/.bin:/Users/dickeyxxx/.cargo/bin
Yarn version:
0.27.5
Node version:
@jdx
jdx / heroku.rb
Created June 27, 2017 20:50
heroku npm homebrew formula
require 'language/node'
class Heroku < Formula
desc "Command-line client for the cloud PaaS"
homepage "https://cli.heroku.com"
url "https://registry.npmjs.org/heroku-cli/-/heroku-cli-6.11.17.tgz"
version "6.11.17"
sha256 "3242779e9103706c3264d6919aed20b20068d21048b12a6b9179564da631ecf1"
head "https://github.com/heroku/cli.git"
@jdx
jdx / snapcraft.yaml
Last active June 6, 2017 22:34 — forked from evandandrea/snapcraft.yaml
heroku
name: heroku
summary: Heroku CLI
description: Heroku CLI
version: "6.9.3"
confinement: strict
grade: stable
apps:
heroku:
command: heroku
plugs: [network]