Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get runner from the "packageManager" field in package.json #89

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"extends": "prettier",
"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 2023,
"sourceType": "module",
"allowImportExportEverywhere": true
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
Session.vim
vimrc
coverage
/.tap/
42 changes: 21 additions & 21 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

"use strict";

const os = require("os");
const path = require("path");
const { execSync } = require("child_process");
import os from "os"
import path from "path"
import { execSync } from "child_process"

const yargs = require("yargs/yargs");
const ipt = require("ipt");
const out = require("simple-output");
const readPkg = require("read-pkg");
const Cache = require("lru-cache-fs");
import yargs from "yargs/yargs"
import ipt from "ipt"
import out from "simple-output"
import { readPackageSync } from "read-pkg"
import Cache from "lru-cache-fs"

const sep = os.EOL;
const defaultRunner = "npm";
Expand Down Expand Up @@ -66,8 +66,9 @@ const {
rerunCacheName,
size
} = argv;
const { ntl, scripts } = getCwdPackage() || {};
const runner = (ntl && ntl.runner) || process.env.NTL_RUNNER || defaultRunner;
const { ntl, scripts, packageManager = '' } = getCwdPackage() || {};
const [corepackRunner] = packageManager.split('@')
const runner = (ntl && ntl.runner) || process.env.NTL_RUNNER || corepackRunner || defaultRunner;
const { descriptions = {} } = ntl || {};
const scriptKeys = Object.keys(scripts || {});
const noScriptsFound = !scripts || scriptKeys.length < 1;
Expand Down Expand Up @@ -112,7 +113,7 @@ function getTrailingOptions() {

function getCwdPackage() {
try {
return readPkg.sync({ cwd });
return readPackageSync({ cwd });
} catch (e) {
const [errorType] = Object.values(e);
error(
Expand Down Expand Up @@ -225,14 +226,14 @@ function run() {
name:
argv.info || argv.descriptions
? getLongName(
key,
argv.descriptions && descriptions[key]
? descriptions[key]
: scripts[key]
)
key,
argv.descriptions && descriptions[key]
? descriptions[key]
: scripts[key]
)
: hasDescriptions
? getLongName(key, descriptions[key])
: key,
? getLongName(key, descriptions[key])
: key,
value: key
}))
.filter(
Expand All @@ -255,9 +256,8 @@ function run() {
)
);

const message = `Select a task to run${
runner !== defaultRunner ? ` (using ${runner})` : ""
}:`;
const message = `Select a task to run${runner !== defaultRunner ? ` (using ${runner})` : ""
}:`;

if (hasCachedTasks()) {
return;
Expand Down
Loading