Skip to content

Commit

Permalink
Merge pull request #28 from DefinitelyTyped/use-tmp-for-npm-downloads
Browse files Browse the repository at this point in the history
Use tmp for npm downloads
  • Loading branch information
sandersn committed Nov 29, 2021
1 parent ddbfcca commit ff13e61
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 48 deletions.
12 changes: 4 additions & 8 deletions packages/dts-critic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import fs = require("fs");
import cp = require("child_process");
import path = require("path");
import semver = require("semver");
import rimraf = require("rimraf");
import { sync as commandExistsSync } from "command-exists";
import ts from "typescript";
import * as tmp from "tmp";

export enum ErrorKind {
/** Declaration is marked as npm in header and has no matching npm package. */
Expand Down Expand Up @@ -105,15 +105,11 @@ If you want to check the declaration against the JavaScript source code, you mus
sourceEntry = sourcePath;
}
else {
packagePath = downloadNpmPackage(name, npmVersion, sourceDir)
const tempDirName = tmp.dirSync({ unsafeCleanup: true }).name
packagePath = downloadNpmPackage(name, npmVersion, tempDirName)
sourceEntry = require.resolve(path.resolve(packagePath));
}
const errors = checkSource(name, dtsPath, sourceEntry, options.errors, debug);
if (packagePath) {
// Delete the source afterward to avoid running out of space
rimraf.sync(packagePath)
}
return errors;
return checkSource(name, dtsPath, sourceEntry, options.errors, debug);
}

return [];
Expand Down
59 changes: 21 additions & 38 deletions packages/dts-critic/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/dts-critic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dependencies": {
"@definitelytyped/header-parser": "0.0.34",
"command-exists": "^1.2.8",
"rimraf": "^3.0.2",
"semver": "^6.2.0",
"tmp": "^0.2.1",
"typescript": "^3.9.2",
"yargs": "^12.0.5"
},
Expand Down Expand Up @@ -38,9 +38,9 @@
"@types/command-exists": "^1.2.0",
"@types/jest": "^24.0.0",
"@types/node": "~10.17.0",
"@types/rimraf": "^3.0.0",
"@types/semver": "^6.0.1",
"@types/strip-json-comments": "0.0.30",
"@types/tmp": "^0.2.0",
"@types/yargs": "^12.0.8",
"@typescript-eslint/eslint-plugin": "^2.3.2",
"@typescript-eslint/experimental-utils": "^2.3.2",
Expand Down

0 comments on commit ff13e61

Please sign in to comment.