Skip to content

Commit af509b0

Browse files
authored
tabtab adjusts (#878)
1 parent d7b6e0b commit af509b0

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

lib/cli.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import rootCheck from 'root-check';
1010
import meow from 'meow';
1111
import list from 'cli-list';
1212
import {bootstrap} from 'global-agent';
13-
import tabtab from './completion/tabtab.cjs';
13+
import Tabtab from './completion/tabtab.cjs';
1414
import pkg from './utils/project-package.js';
1515
import Router from './router.js';
1616
import * as routes from './routes/index.js';
@@ -63,6 +63,13 @@ async function pre() {
6363
}
6464

6565
if (cmd === 'completion') {
66+
// eslint-disable-next-line new-cap
67+
const tabtab = new Tabtab.Commands.default({
68+
name: 'yo',
69+
completer: 'yo-complete',
70+
cache: false,
71+
});
72+
6673
return tabtab.install();
6774
}
6875

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const path = require('node:path');
2-
const {execFile} = require('node:child_process');
3-
const parseHelp = require('parse-help');
1+
import path from 'node:path';
2+
import {execFile} from 'node:child_process';
3+
import parseHelp from 'parse-help';
4+
import {getDirname} from '../utils/node-shims.js';
45

56
/**
67
* The Completer is in charge of handling `yo-complete` behavior.
@@ -38,7 +39,7 @@ class Completer {
3839
*/
3940
generator(data, done) {
4041
const {last} = data;
41-
const binary = path.resolve(__dirname, '../cli.js');
42+
const binary = path.resolve(getDirname(import.meta.url), '../cli.js');
4243

4344
execFile('node', [binary, last, '--help'], (error, out) => {
4445
if (error) {
@@ -102,4 +103,4 @@ class Completer {
102103
}
103104
}
104105

105-
module.exports = Completer;
106+
export default Completer;

lib/completion/index.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#! /usr/bin/env node
2-
const tabtab = require('tabtab')({
2+
const tabtab = require('./tabtab.cjs')({
33
name: 'yo',
44
cache: !require('node:process').env.YO_TEST,
55
});
6-
const Completer = require('./completer.cjs');
76

87
(async () => {
98
const {createEnv} = await import('yeoman-environment');
9+
const {default: Completer} = await import('./completer.js');
1010
const completer = new Completer(createEnv());
1111

1212
tabtab.completer = completer;

lib/completion/tabtab.cjs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
const Tabtab = require('tabtab');
2-
3-
// eslint-disable-next-line new-cap
4-
const tabtab = new Tabtab.Commands.default({
5-
name: 'yo',
6-
completer: 'yo-complete',
7-
cache: false,
8-
});
1+
const tabtab = require('tabtab');
92

103
module.exports = tabtab;

test/completion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import events from 'node:events';
44
import {execFileSync} from 'node:child_process';
55
import os from 'node:os';
66
import _ from 'lodash';
7-
import Completer from '../lib/completion/completer.cjs';
7+
import Completer from '../lib/completion/completer.js';
88
import completion from '../lib/completion/index.cjs';
99
import {getDirname} from '../lib/utils/node-shims.js';
1010

0 commit comments

Comments
 (0)