Skip to content

Commit

Permalink
Merge pull request #38 from jasonkneen/feature/node20
Browse files Browse the repository at this point in the history
feat: support Node.js 20, update commander
  • Loading branch information
hansemannn authored Jul 28, 2024
2 parents 893c162 + 6a0bbd0 commit 96ddb4d
Show file tree
Hide file tree
Showing 4 changed files with 627 additions and 442 deletions.
20 changes: 11 additions & 9 deletions bin.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env node

var program = require('commander'),
_ = require('underscore'),
config = require('./config'),
main = require('./main');
const commander = require('commander');
const _ = require('underscore');
const config = require('./config');
const main = require('./main');

const program = new commander.Command()

program
.version(config.package.version, '-v, --version')
Expand All @@ -15,7 +17,7 @@ _.each(config.commands, function(config, name) {

// for the CLI
if (config.cli !== false) {
var usage = name;
let usage = name;

// args
if (config.args) {
Expand All @@ -26,12 +28,12 @@ _.each(config.commands, function(config, name) {
}

// command
var command = program.command(usage)
const command = program.command(usage)
.description(config.desc.grey)
.action(function() {

// format like we get it when being an hook
var args = _.flatten(arguments),
const args = _.flatten(arguments),
argv = args.pop();
argv._ = args;

Expand All @@ -49,7 +51,7 @@ _.each(config.commands, function(config, name) {
// flags
if (config.flags) {
_.each(config.flags, function(cf, flag) {
var inst = [];
let inst = [];

if (cf.abbr) {
inst.push('-' + cf.abbr);
Expand All @@ -64,7 +66,7 @@ _.each(config.commands, function(config, name) {
// options
if (config.options) {
_.each(config.options, function(cf, option) {
var inst = [];
let inst = [];

if (cf.abbr) {
inst.push('-' + cf.abbr);
Expand Down
16 changes: 7 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
var fs = require("fs"),
path = require("path"),
fields = require('fields'),
_ = require('underscore'),
exec = require('exec'),
config = require('./config'),
logger = require("./lib/logger");
const path = require('path');
const _ = require('underscore');
const exec = require('exec');
const config = require('./config');
const logger = require("./lib/logger");

// Execute a shell command
function execute(executable, params, callback) {
Expand Down Expand Up @@ -51,8 +49,8 @@ exports.plugged = function(env, callback) {
logger.error(err);

} else {
var object = JSON.parse(out),
plugged = _.contains(object.paths.commands, path.join(__dirname, 'commands'));
const object = JSON.parse(out);
const plugged = _.contains(object.paths.commands, path.join(__dirname, 'commands'));

if (_.isFunction(callback)) {
callback(plugged);
Expand Down
Loading

0 comments on commit 96ddb4d

Please sign in to comment.