@netlify/framework-info
Advanced tools
Comparing version 9.5.1 to 9.5.2
{ | ||
"name": "@netlify/framework-info", | ||
"version": "9.5.1", | ||
"version": "9.5.2", | ||
"description": "Framework detection utility", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -66,3 +66,3 @@ import pFilter from 'p-filter' | ||
* | ||
* @returns {Framework[]} frameworks - Frameworks used by a project | ||
* @returns {Promise<Framework[]>} frameworks - Frameworks used by a project | ||
*/ | ||
@@ -89,3 +89,3 @@ export const listFrameworks = async function (context) { | ||
* | ||
* @returns {boolean} result - Whether the project uses this framework | ||
* @returns {Promise<boolean>} result - Whether the project uses this framework | ||
*/ | ||
@@ -106,3 +106,3 @@ export const hasFramework = async function (frameworkId, context) { | ||
* | ||
* @returns {Framework} framework - Framework used by a project | ||
* @returns {Promise<Framework>} framework - Framework used by a project | ||
*/ | ||
@@ -109,0 +109,0 @@ export const getFramework = async function (frameworkId, context) { |
import { join } from 'path' | ||
import { cwd, chdir } from 'process' | ||
import { cwd } from 'process' | ||
@@ -56,9 +56,5 @@ import { findUp } from 'find-up' | ||
const getFrameworkVersion = async (projectDir, frameworkInfo) => { | ||
// Need to change the CWD to the project directory in order to make sure we find and use the correct | ||
// package.json | ||
const originalCwd = cwd() | ||
const returnToOriginalDirectory = () => { | ||
chdir(originalCwd) | ||
if (!frameworkInfo.package || !frameworkInfo.package.name) { | ||
return frameworkInfo | ||
} | ||
chdir(projectDir) | ||
@@ -70,11 +66,9 @@ const npmPackage = frameworkInfo.package.name | ||
// has been hoisted to the root directory of the project (which differs from the directory of the project/application being built) | ||
const installedFrameworkPath = await findUp(join('node_modules', npmPackage, 'package.json')) | ||
const installedFrameworkPath = await findUp(join('node_modules', npmPackage, 'package.json'), { cwd: projectDir }) | ||
const { packageJson } = await getPackageJson(installedFrameworkPath) | ||
returnToOriginalDirectory() | ||
return { | ||
...frameworkInfo, | ||
package: { | ||
name: frameworkInfo.package.name, | ||
name: npmPackage, | ||
version: packageJson.version || 'unknown', | ||
@@ -90,3 +84,3 @@ }, | ||
* | ||
* @returns {Framework[]} frameworks - Frameworks used by a project | ||
* @returns {Promise<Framework[]>} frameworks - Frameworks used by a project | ||
*/ | ||
@@ -102,4 +96,10 @@ export const listFrameworks = async function (opts) { | ||
) | ||
const updatedList = settledPromises.map((result) => result.value) | ||
const updatedList = settledPromises.map((result) => { | ||
if (result.status === 'fulfilled') { | ||
return result.value | ||
} | ||
throw result.reason | ||
}) | ||
return updatedList | ||
@@ -114,7 +114,7 @@ } | ||
* | ||
* @returns {boolean} result - Whether the project uses this framework | ||
* @returns {Promise<boolean>} result - Whether the project uses this framework | ||
*/ | ||
export const hasFramework = async function (frameworkId, options) { | ||
const context = await getContext(options) | ||
return await has(frameworkId, context) | ||
return has(frameworkId, context) | ||
} | ||
@@ -126,9 +126,9 @@ | ||
* @param {string} frameworkId - Id such as `"gatsby"` | ||
* @param {Context} [context] - Context | ||
* @param {Options} [options] - Context | ||
* | ||
* @returns {Framework} framework - Framework used by a project | ||
* @returns {Promise<Framework>} framework - Framework used by a project | ||
*/ | ||
export const getFramework = async function (frameworkId, options) { | ||
const context = await getContext(options) | ||
return await get(frameworkId, context) | ||
return get(frameworkId, context) | ||
} |
Sorry, the diff of this file is not supported yet
261192
2961