Skip to content

Commit

Permalink
npx oclif single [...]
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Alemayhu <[email protected]>
  • Loading branch information
aalemayhu committed Jan 5, 2019
0 parents commit db72944
Show file tree
Hide file tree
Showing 11 changed files with 1,895 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "oclif"
}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*-debug.log
*-error.log
/.nyc_output
/dist
/package-lock.json
/tmp
node_modules
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@jamstack-oslo/last-tuesday-in
==============================

show the last tuesdays

[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/@jamstack-oslo/last-tuesday-in.svg)](https://npmjs.org/package/@jamstack-oslo/last-tuesday-in)
[![Downloads/week](https://img.shields.io/npm/dw/@jamstack-oslo/last-tuesday-in.svg)](https://npmjs.org/package/@jamstack-oslo/last-tuesday-in)
[![License](https://img.shields.io/npm/l/@jamstack-oslo/last-tuesday-in.svg)](https://github.com/JAMstack-Oslo/last-tuesday-in/blob/master/package.json)

<!-- toc -->
# Usage
<!-- usage -->
# Commands
<!-- commands -->
4 changes: 4 additions & 0 deletions bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node

require('..').run()
.catch(require('@oclif/errors/handle'))
3 changes: 3 additions & 0 deletions bin/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\run" %*
44 changes: 44 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "@jamstack-oslo/last-tuesday-in",
"description": "show the last tuesdays",
"version": "0.0.0",
"author": "Alexander Alemayhu @scanf",
"bin": {
"last-tuesday-in": "./bin/run"
},
"bugs": "https://github.com/JAMstack-Oslo/last-tuesday-in/issues",
"dependencies": {
"@oclif/command": "^1",
"@oclif/config": "^1",
"@oclif/plugin-help": "^2"
},
"devDependencies": {
"@oclif/test": "^1",
"chai": "^4",
"eslint": "^5.5",
"eslint-config-oclif": "^3.1",
"mocha": "^5",
"nyc": "^13"
},
"engines": {
"node": ">=8.0.0"
},
"files": [
"/bin",
"/src"
],
"homepage": "https://github.com/JAMstack-Oslo/last-tuesday-in",
"keywords": [
"oclif"
],
"license": "MIT",
"main": "src/index.js",
"oclif": {
"bin": "last-tuesday-in"
},
"repository": "JAMstack-Oslo/last-tuesday-in",
"scripts": {
"posttest": "eslint .",
"test": "nyc mocha --forbid-only \"test/**/*.test.js\""
}
}
24 changes: 24 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const {Command, flags} = require('@oclif/command')

class JamstackOsloLastTuesdayInCommand extends Command {
async run() {
const {flags} = this.parse(JamstackOsloLastTuesdayInCommand)
const name = flags.name || 'world'
this.log(`hello ${name} from ./src/index.js`)
}
}

JamstackOsloLastTuesdayInCommand.description = `Describe the command here
...
Extra documentation goes here
`

JamstackOsloLastTuesdayInCommand.flags = {
// add --version flag to show CLI version
version: flags.version({char: 'v'}),
// add --help flag to show CLI version
help: flags.help({char: 'h'}),
name: flags.string({char: 'n', description: 'name to print'}),
}

module.exports = JamstackOsloLastTuesdayInCommand
18 changes: 18 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const {expect, test} = require('@oclif/test')
const cmd = require('..')

describe('@jamstack-oslo/last-tuesday-in', () => {
test
.stdout()
.do(() => cmd.run([]))
.it('runs hello', ctx => {
expect(ctx.stdout).to.contain('hello world')
})

test
.stdout()
.do(() => cmd.run(['--name', 'jeff']))
.it('runs hello --name jeff', ctx => {
expect(ctx.stdout).to.contain('hello jeff')
})
})
3 changes: 3 additions & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--recursive
--reporter spec
--timeout 5000
Loading

0 comments on commit db72944

Please sign in to comment.