action-this.js
This file
Path
examples/action-this.js
19 lines · 478 bytes · JavaScript
Last changed by
Use standard import in examples (#2168)John Geebefore adoption41b12cf
History of this fileTake it
Merge pull request #1683 from tj/release/9.xJohn Geebefore adoption02a124c
lines 1–4why, one step back1#!/usr/bin/env node23// This example is used as an example in the README for the action handler.4Use standard import in examples (#2168)John Geebefore adoption41b12cf
line 5why, one step back5const { Command } = require('commander');Merge pull request #1683 from tj/release/9.xJohn Geebefore adoption02a124c
lines 6–19why, one step back6const program = new Command();78program9 .command('serve')10 .argument('<script>')11 .option('-p, --port <number>', 'port number', 80)12 .action(function() {13 console.error('Run script %s on port %s', this.args[0], this.opts().port);14 });1516program.parse();1718// Try the following:19// node action-this.js serve --port 8080 index.js