Skip to content

Commit

Permalink
Fix circular dependency in get-format
Browse files Browse the repository at this point in the history
  • Loading branch information
brawaru committed Mar 6, 2023
1 parent cf9de89 commit a764973
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/get-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import path from 'node:path'
import {URL, fileURLToPath} from 'node:url'
import {getPackageType} from './resolve.js'
import {getPackageType} from './package-type.js'
import {codes} from './errors.js'

const {ERR_UNKNOWN_FILE_EXTENSION} = codes
Expand Down
14 changes: 14 additions & 0 deletions lib/package-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {getPackageScopeConfig} from './package-config.js'

/**
* @typedef {import('./package-config.js').PackageType} PackageType
*/

/**
* @param {URL} url
* @returns {PackageType}
*/
export function getPackageType(url) {
const packageConfig = getPackageScopeConfig(url)
return packageConfig.type
}
10 changes: 0 additions & 10 deletions lib/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
/**
* @typedef {import('./errors.js').ErrnoException} ErrnoException
* @typedef {import('./package-config.js').PackageConfig} PackageConfig
* @typedef {import('./package-config.js').PackageType} PackageType
*/

import assert from 'node:assert'
Expand Down Expand Up @@ -883,15 +882,6 @@ function packageImportsResolve(name, base, conditions) {
throw importNotDefined(name, packageJsonUrl, base)
}

/**
* @param {URL} url
* @returns {PackageType}
*/
export function getPackageType(url) {
const packageConfig = getPackageScopeConfig(url)
return packageConfig.type
}

/**
* @param {string} specifier
* @param {URL} base
Expand Down

0 comments on commit a764973

Please sign in to comment.