Skip to content

Commit

Permalink
refactor: extract realpath native into a separate module (#5097)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored and cpojer committed Dec 17, 2017
1 parent fb10f7a commit de004b6
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/jest-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"jest-worker": "^21.2.1",
"micromatch": "^2.3.11",
"node-notifier": "^5.1.2",
"realpath-native": "^1.0.0",
"rimraf": "^2.5.4",
"slash": "^1.0.0",
"string-length": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
Console,
clearLine,
createDirectory,
realpath,
validateCLIOptions,
} from 'jest-util';
import {readConfig} from 'jest-config';
Expand All @@ -34,6 +33,7 @@ import TestWatcher from '../test_watcher';
import watch from '../watch';
import yargs from 'yargs';
import rimraf from 'rimraf';
import {sync as realpath} from 'realpath-native';

export async function run(maybeArgv?: Argv, project?: Path) {
try {
Expand Down
1 change: 1 addition & 0 deletions packages/jest-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"jest-util": "^21.2.1",
"json-stable-stringify": "^1.0.1",
"micromatch": "^2.3.11",
"realpath-native": "^1.0.0",
"slash": "^1.0.0",
"strip-bom": "3.0.0",
"write-file-atomic": "^2.1.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-runtime/src/script_transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
import crypto from 'crypto';
import path from 'path';
import vm from 'vm';
import {createDirectory, realpath} from 'jest-util';
import {createDirectory} from 'jest-util';
import fs from 'graceful-fs';
import {transform as babelTransform} from 'babel-core';
import babelPluginIstanbul from 'babel-plugin-istanbul';
Expand All @@ -28,6 +28,7 @@ import slash from 'slash';
import {version as VERSION} from '../package.json';
import shouldInstrument from './should_instrument';
import writeFileAtomic from 'write-file-atomic';
import {sync as realpath} from 'realpath-native';

export type Options = {|
collectCoverage: boolean,
Expand Down
11 changes: 0 additions & 11 deletions packages/jest-util/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/

import mkdirp from 'mkdirp';
import fs from 'fs';

import BufferedConsole from './buffered_console';
import clearLine from './clear_line';
Expand All @@ -32,15 +31,6 @@ const createDirectory = (path: string) => {
}
};

const realpath = (filepath: string) => {
if (typeof fs.realpathSync.native === 'function') {
return fs.realpathSync.native(filepath);
}

// $FlowFixMe: This is need for node@<9.2
return process.binding('fs').realpath(filepath, 'utf8');
};

module.exports = {
BufferedConsole,
Console,
Expand All @@ -52,7 +42,6 @@ module.exports = {
getConsoleOutput,
installCommonGlobals,
isInteractive,
realpath,
setGlobal,
validateCLIOptions,
};
30 changes: 30 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2633,6 +2633,16 @@ errorhandler@~1.4.2:
accepts "~1.3.0"
escape-html "~1.0.3"

es-abstract@^1.5.1:
version "1.10.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.10.0.tgz#1ecb36c197842a00d8ee4c2dfd8646bb97d60864"
dependencies:
es-to-primitive "^1.1.1"
function-bind "^1.1.1"
has "^1.0.1"
is-callable "^1.1.3"
is-regex "^1.0.4"

es-abstract@^1.6.1, es-abstract@^1.7.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.9.0.tgz#690829a07cae36b222e7fd9b75c0d0573eb25227"
Expand Down Expand Up @@ -5369,6 +5379,13 @@ object.entries@^1.0.4:
function-bind "^1.1.0"
has "^1.0.1"

object.getownpropertydescriptors@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16"
dependencies:
define-properties "^1.1.2"
es-abstract "^1.5.1"

object.omit@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa"
Expand Down Expand Up @@ -6139,6 +6156,12 @@ readdirp@^2.0.0:
readable-stream "^2.0.2"
set-immediate-shim "^1.0.1"

realpath-native@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/realpath-native/-/realpath-native-1.0.0.tgz#7885721a83b43bd5327609f0ddecb2482305fdf0"
dependencies:
util.promisify "^1.0.0"

rechoir@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
Expand Down Expand Up @@ -7392,6 +7415,13 @@ [email protected], util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"

util.promisify@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.0.tgz#440f7165a459c9a16dc145eb8e72f35687097030"
dependencies:
define-properties "^1.1.2"
object.getownpropertydescriptors "^2.0.3"

[email protected], util@~0.10.1:
version "0.10.3"
resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9"
Expand Down

0 comments on commit de004b6

Please sign in to comment.