Skip to content

Commit

Permalink
bin: remove epilogue, direct to in-repo docs instead
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavohenke committed Sep 3, 2024
1 parent 3c42827 commit 1151196
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 100 deletions.
7 changes: 5 additions & 2 deletions bin/concurrently.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { hideBin } from 'yargs/helpers';

import * as defaults from '../src/defaults';
import { concurrently } from '../src/index';
import { epilogue } from './epilogue';
import { readPackage } from './read-package';

const version = String(readPackage().version);
const epilogue = `For documentation and more examples, visit:\nhttps://github.com/open-cli-tools/concurrently/tree/v${version}/docs`;

// Clean-up arguments (yargs expects only the arguments after the program name)
const args = yargs(hideBin(process.argv))
Expand All @@ -18,7 +21,7 @@ const args = yargs(hideBin(process.argv))
.usage('$0 [options] <command ...>')
.help('h')
.alias('h', 'help')
.version()
.version(version)
.alias('version', 'v')
.alias('version', 'V')
// TODO: Add some tests for this.
Expand Down
98 changes: 0 additions & 98 deletions bin/epilogue.ts

This file was deleted.

23 changes: 23 additions & 0 deletions bin/read-package.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as fs from 'fs';
import * as path from 'path';

/**
* Traverses the directory tree until a package.json file is found.
*
* @throws if the root directory is reached, and no package.json is found.
*/
export function readPackage(): Record<string, unknown> {
let dir = require.main?.path ?? process.cwd();
let oldDir = dir;
do {
const pkgPath = path.join(dir, 'package.json');
if (fs.existsSync(pkgPath)) {
return JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
}

oldDir = dir;
dir = path.dirname(dir);
} while (oldDir !== dir);

throw new Error('package.json not found');
}

0 comments on commit 1151196

Please sign in to comment.