Comparing version 1.5.1 to 1.5.2
'use strict'; | ||
var promises = require('fs/promises'); | ||
var path$1 = require('path'); | ||
var pathUtils = require('path'); | ||
var fs = require('node:fs/promises'); | ||
@@ -26,2 +26,3 @@ var path = require('node:path'); | ||
var pathUtils__namespace = /*#__PURE__*/_interopNamespaceDefault(pathUtils); | ||
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs); | ||
@@ -137,3 +138,3 @@ var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path); | ||
const PIERRE_CI_PATH = path__namespace.join(process.cwd(), ".pierre", "ci"); | ||
const PIERRE_CI_PATH = path__namespace.join(".pierre", "ci"); | ||
exports.Icons = void 0; | ||
@@ -249,22 +250,24 @@ (function (Icons) { | ||
} | ||
const IMPLICIT_EXTENSIONS = ["ts", "mts", "js"]; | ||
async function resolvePath(path) { | ||
// Try exact path | ||
if (await fsExists(path)) { | ||
return path; | ||
const IMPLICIT_EXTENSIONS = ["ts", "mts", "mjs", "js"]; | ||
function hasExtension(path) { | ||
return pathUtils__namespace.extname(path) !== ""; | ||
} | ||
// Produce an iterator from an input string of possible file paths to search for a job name at | ||
function* resolvePaths(name) { | ||
if (pathUtils__namespace.isAbsolute(name)) { | ||
yield name; | ||
} | ||
// Try adding an implicit extension | ||
const implicitExt = await resolvePathExtensions(path); | ||
if (implicitExt !== undefined) { | ||
return implicitExt; | ||
if (!hasExtension(name)) { | ||
for (const ext of IMPLICIT_EXTENSIONS) { | ||
yield* resolvePaths(`${name}.${ext}`); | ||
} | ||
} | ||
// If we don't contain `.pierre` then pass it back through resolvePath | ||
if (!path.includes(".pierre")) { | ||
return resolvePath(`.pierre/ci/${path}`); | ||
if (!pathUtils__namespace.isAbsolute(name)) { | ||
yield* resolvePaths(pathUtils__namespace.join(process.cwd(), name)); | ||
yield* resolvePaths(pathUtils__namespace.join(process.cwd(), PIERRE_CI_PATH, name)); | ||
} | ||
throw new Error(`Unable to resolve job ${path}`); | ||
} | ||
async function resolvePathExtensions(partialPath) { | ||
for (const ext of IMPLICIT_EXTENSIONS) { | ||
const path = `${partialPath}.${ext}`; | ||
async function resolvePath(name) { | ||
for (const path of resolvePaths(name)) { | ||
console.log(path); | ||
if (await fsExists(path)) { | ||
@@ -274,3 +277,3 @@ return path; | ||
} | ||
return undefined; | ||
throw new Error(`Unable to resolve job ${name}`); | ||
} | ||
@@ -293,3 +296,3 @@ async function requireJob(raw) { | ||
else { | ||
return path$1.basename(path, path$1.extname(path)); | ||
return pathUtils__namespace.basename(path, pathUtils__namespace.extname(path)); | ||
} | ||
@@ -313,3 +316,4 @@ } | ||
async function describeJobs() { | ||
const dirents = await promises.readdir(PIERRE_CI_PATH, { | ||
const path = pathUtils__namespace.join(process.cwd(), PIERRE_CI_PATH); | ||
const dirents = await promises.readdir(path, { | ||
withFileTypes: true, | ||
@@ -326,8 +330,7 @@ recursive: false, | ||
jobs: await Promise.all(files.map(async (filename) => { | ||
const path = `${PIERRE_CI_PATH}/${filename}`; | ||
return { | ||
label: await getJobLabel(path), | ||
label: await getJobLabel(`${path}/${filename}`), | ||
commands: [ | ||
await getPackageManagerCommand(), | ||
buildNodeRunCommand(path$1.relative(process.cwd(), filename)), | ||
buildNodeRunCommand(filename), | ||
], | ||
@@ -334,0 +337,0 @@ }; |
{ | ||
"name": "pierre", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "Pierre is a CLI / Node library for interacting with git + pierre.co", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
385038
12465