@vercel/build-utils
Advanced tools
Comparing version 2.4.2-canary.0 to 2.4.2-canary.1
/// <reference types="node" /> | ||
import { SpawnOptions } from 'child_process'; | ||
import { Meta, NodeVersion, Config } from '../types'; | ||
import { Meta, PackageJson, NodeVersion, Config } from '../types'; | ||
interface SpawnOptionsExtended extends SpawnOptions { | ||
@@ -41,3 +41,4 @@ prettyCommand?: string; | ||
export declare function runPipInstall(destPath: string, args?: string[], spawnOpts?: SpawnOptions, meta?: Meta): Promise<void>; | ||
export declare function runPackageJsonScript(destPath: string, scriptName: string, spawnOpts?: SpawnOptions): Promise<boolean>; | ||
export declare function getScriptName(pkg: Pick<PackageJson, 'scripts'> | null | undefined, possibleNames: Iterable<string>): string | null; | ||
export declare function runPackageJsonScript(destPath: string, scriptNames: string | Iterable<string>, spawnOpts?: SpawnOptions): Promise<boolean>; | ||
/** | ||
@@ -44,0 +45,0 @@ * @deprecate installDependencies() is deprecated. |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.installDependencies = exports.runPackageJsonScript = exports.runPipInstall = exports.runBundleInstall = exports.runNpmInstall = exports.walkParentDirs = exports.getNodeVersion = exports.getSpawnOptions = exports.runShellScript = exports.getNodeBinPath = exports.execCommand = exports.spawnCommand = exports.execAsync = exports.spawnAsync = void 0; | ||
exports.installDependencies = exports.runPackageJsonScript = exports.getScriptName = exports.runPipInstall = exports.runBundleInstall = exports.runNpmInstall = exports.walkParentDirs = exports.getNodeVersion = exports.getSpawnOptions = exports.runShellScript = exports.getNodeBinPath = exports.execCommand = exports.spawnCommand = exports.execAsync = exports.spawnAsync = void 0; | ||
const assert_1 = __importDefault(require("assert")); | ||
@@ -251,11 +251,21 @@ const fs_extra_1 = __importDefault(require("fs-extra")); | ||
exports.runPipInstall = runPipInstall; | ||
async function runPackageJsonScript(destPath, scriptName, spawnOpts) { | ||
function getScriptName(pkg, possibleNames) { | ||
if (pkg && pkg.scripts) { | ||
for (const name of possibleNames) { | ||
if (name in pkg.scripts) { | ||
return name; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
exports.getScriptName = getScriptName; | ||
async function runPackageJsonScript(destPath, scriptNames, spawnOpts) { | ||
assert_1.default(path_1.default.isAbsolute(destPath)); | ||
const { packageJson, cliType } = await scanParentDirs(destPath, true); | ||
const hasScript = Boolean(packageJson && | ||
packageJson.scripts && | ||
scriptName && | ||
packageJson.scripts[scriptName]); | ||
if (!hasScript) | ||
const scriptName = getScriptName(packageJson, typeof scriptNames === 'string' ? [scriptNames] : scriptNames); | ||
if (!scriptName) | ||
return false; | ||
debug_1.default('Running user script...'); | ||
const runScriptTime = Date.now(); | ||
if (cliType === 'npm') { | ||
@@ -279,2 +289,3 @@ const prettyCommand = `npm run ${scriptName}`; | ||
} | ||
debug_1.default(`Script complete [${Date.now() - runScriptTime}ms]`); | ||
return true; | ||
@@ -281,0 +292,0 @@ } |
@@ -10,3 +10,3 @@ import FileBlob from './file-blob'; | ||
import rename from './fs/rename'; | ||
import { execAsync, spawnAsync, execCommand, spawnCommand, walkParentDirs, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, getNodeVersion, getSpawnOptions, getNodeBinPath } from './fs/run-user-scripts'; | ||
import { execAsync, spawnAsync, execCommand, spawnCommand, walkParentDirs, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, getNodeVersion, getSpawnOptions, getNodeBinPath } from './fs/run-user-scripts'; | ||
import { getLatestNodeVersion, getDiscontinuedNodeVersions } from './fs/node-version'; | ||
@@ -16,3 +16,3 @@ import streamToBuffer from './fs/stream-to-buffer'; | ||
import debug from './debug'; | ||
export { FileBlob, FileFsRef, FileRef, Lambda, createLambda, Prerender, download, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, execAsync, spawnAsync, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, getNodeVersion, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, streamToBuffer, shouldServe, debug, isSymbolicLink, getLambdaOptionsFromFunction, }; | ||
export { FileBlob, FileFsRef, FileRef, Lambda, createLambda, Prerender, download, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, execAsync, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, getNodeVersion, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, streamToBuffer, shouldServe, debug, isSymbolicLink, getLambdaOptionsFromFunction, }; | ||
export { detectBuilders, detectOutputDirectory, detectApiDirectory, detectApiExtensions, } from './detect-builders'; | ||
@@ -19,0 +19,0 @@ export { detectFramework } from './detect-framework'; |
{ | ||
"name": "@vercel/build-utils", | ||
"version": "2.4.2-canary.0", | ||
"version": "2.4.2-canary.1", | ||
"license": "MIT", | ||
@@ -51,3 +51,3 @@ "main": "./dist/index.js", | ||
}, | ||
"gitHead": "1a1271509609ff0e48f947d61f0a267798238cd7" | ||
"gitHead": "727ae587dbe3582f85e252ff32c57f70c41e7c1c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1246757
30619