Skip to content

Commit

Permalink
chore: remove pointless function
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Feb 5, 2024
1 parent 26c54c2 commit 22ed657
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
6 changes: 3 additions & 3 deletions packages/endomoat/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import path from 'node:path'
import yargs from 'yargs'
import { hideBin } from 'yargs/helpers'
import * as constants from './constants.js'
import { absolutify, resolveFrom } from './util.js'
import { resolveFrom } from './util.js'

yargs(hideBin(process.argv))
/**
Expand Down Expand Up @@ -118,8 +118,8 @@ yargs(hideBin(process.argv))
* Ensures policy paths are absolute, resolved from `cwd`
*/
function resolvePolicyPaths(argv) {
argv.policy = absolutify(argv.policy)
argv.policyOverride = absolutify(argv.policyOverride)
argv.policy = path.resolve(argv.policy)
argv.policyOverride = path.resolve(argv.policyOverride)
},
]
)
Expand Down
24 changes: 9 additions & 15 deletions packages/endomoat/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import path from 'node:path'

/**
* Resolves a module from a given directory
*
* @overload
* @param {string} cwd - The directory to resolve from
* @param {string} moduleId - The module to resolve
Expand All @@ -12,14 +13,18 @@ import path from 'node:path'

/**
* Resolves a module from the current working directory
*
* @overload
* @param {string} moduleId - The module to resolve
* @returns {string} The resolved module
*/

/**
* Resolves a module from the given directory or from the current working directory
* @param {string} cwdOrModuleId - The directory to resolve from or the module to resolve
* Resolves a module from the given directory or from the current working
* directory
*
* @param {string} cwdOrModuleId - The directory to resolve from or the module
* to resolve
* @param {string} [allegedModuleId] - The module to resolve
* @returns {string} The resolved module
*/
Expand All @@ -38,22 +43,11 @@ export function resolveFrom(cwdOrModuleId, allegedModuleId) {
/**
* Reads a JSON file
*
* @template [T=unknown]
* @param {string|URL} filepath
* @template [T=unknown] Default is `unknown`
* @param {string | URL} filepath
* @returns {Promise<T>}
*/
export async function readJsonFile(filepath) {
const json = await fs.readFile(filepath, 'utf8')
return JSON.parse(json)
}

/**
* Makes a path absolute if it isn't already
*
* @param {string} filepath - Path to make absolute
* @param {string} [cwd] - Current working directory
* @returns {string}
*/
export function absolutify(filepath, cwd = process.cwd()) {
return path.isAbsolute(filepath) ? filepath : path.resolve(cwd, filepath)
}

0 comments on commit 22ed657

Please sign in to comment.