#!/usr/bin/env node import { SpawnSyncReturns } from 'child_process'; export declare type PackageJson = { "name"?: string; "version"?: string; "dependencies"?: any; "devDependencies"?: any; "optionalDependencies"?: any; "scripts"?: any; "testpack"?: any; "files"?: any; }; export declare type ImportMatcher = { exts: string[]; regex: string | RegExp; regexOptions?: string; }; export interface Options { "test-files": string[]; "nontest"?: string[]; "packagejson"?: any; "packagejson-file"?: string; "replace-import"?: string[]; "replace-test-imports"?: boolean; "regex"?: ImportMatcher[]; "install"?: string[]; "keep"?: string[]; "test-folder"?: string; "rmdir"?: boolean; "dirty"?: boolean; "setup-command"?: string; "noinstall"?: boolean; "test-script"?: string; "verbose"?: boolean; "delete-on-fail"?: boolean; "prepacked"?: string | boolean; } /** * Implements the testpack command-line tool. * @param opts Options */ export declare function testPack(opts: Options): SpawnSyncReturns; export declare const defaultTestPatterns: string[]; /** Converts args (produced by minimist or read from package.json) * to the Options interface and performs type checking. */ export declare function refineOptions(args: any): Options; export declare function readPackageJson(filename?: string): PackageJson; export declare function combineOptions(pkg: PackageJson, opts: Options): Options; export declare function transformPackageJson(pkg: PackageJson, opts: Options): PackageJson; export declare function getNameWithoutSlash(pkg: PackageJson): string; export declare function runNpmPack(pkg: PackageJson, opts: Options): string; export declare function getTestFiles(opts: Options, fromFolder?: string): string[]; export declare function copyFileTree(files: string[], fromFolder: string, toFolder: string): void; /** Helper class for transforming import/require commands */ export declare class ImportTransformer { opts: Options; packageName: string; replacementPairs: [RegExp, string][]; constructor(opts: Options, packageName: string); /** Reads a set of test files and scans it for import/require commands, * performing replacements on those. * @param opts opts.regex (combined with defaultRegexes) specifies how * to find import strings, and opts['replace-import'] controls * replacement patterns. Files that appear to be test files * (opts['test-files']) are normally left unchanged. */ transformAllImports(testFiles: string[]): number; transformImports(inputFile: string, outputFile: string): boolean; /** Scans a test file's lines for import/require commands via regex, * performing replacements on those. Regexes are imperfect but save * us the trouble of importing some huge JS/TS parser (and also allow * users to support languages other than JS/TS.) * @param matchers Regular expressions used to locate import/require. * First capture group must be the filename. Don't use "g" option. * @param opts opts.regex (combined with defaultRegexes) specifies how * to find import strings, and opts['replace-import'] controls * replacement patterns. Files that appear to be test files * (opts['test-files'] except opts.nontest) are left unchanged * unless opts["replace-test-imports"] is true. * @param replacementPairs optional: cached interpretation of * opts['replace-import'] */ transformImportsCore(lines: string[], matchers: RegExp[]): boolean; static getReplacementPairs(pkgName: string, patterns?: string[]): [RegExp, string][]; static jsExts: string[]; static defaultRegexes: ImportMatcher[]; /** Gets regexes for finding import/require expressions in a particular file * based on opts.regex. */ getMatchersFor(fileName: string): RegExp[]; } export declare function evalToObject(data: string): any; export declare function merge(oldVal: any, newVal: any): any; export declare function mergeObjects(oldVal: any, newVal: any): any;