Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-changed-files

Package Overview
Dependencies
Maintainers
2
Versions
175
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-changed-files - npm Package Compare versions

Comparing version 20.1.0-alpha.3 to 20.1.0-beta.1

types.js

105

build/git.js

@@ -13,60 +13,57 @@ 'use strict';

var _path = require('path');var _path2 = _interopRequireDefault(_path);
var _child_process = require('child_process');var _child_process2 = _interopRequireDefault(_child_process);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
var _child_process = require('child_process');var _child_process2 = _interopRequireDefault(_child_process);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};} /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const adapter = { findChangedFiles: (() => {var _ref = _asyncToGenerator(function* (cwd, options) {return new Promise(function (resolve, reject) {const args =
options && options.lastCommit ?
['show', '--name-only', '--pretty=%b', 'HEAD'] :
['ls-files', '--other', '--modified', '--exclude-standard'];
const child = _child_process2.default.spawn('git', args, { cwd });
let stdout = '';
let stderr = '';
child.stdout.on('data', function (data) {return stdout += data;});
child.stderr.on('data', function (data) {return stderr += data;});
child.on('error', function (e) {return reject(e);});
child.on('close', function (code) {
if (code === 0) {
stdout = stdout.trim();
if (stdout === '') {
resolve([]);
} else {
resolve(
stdout.
split('\n').
map(function (changedPath) {return _path2.default.resolve(cwd, changedPath);}));
}
} else {
reject(code + ': ' + stderr);
}
});
});
});return function findChangedFiles(_x, _x2) {return _ref.apply(this, arguments);};})(),
getRoot: (() => {var _ref2 = _asyncToGenerator(function* (cwd) {
return new Promise(function (resolve) {
try {
let stdout = '';
const options = ['rev-parse', '--show-toplevel'];
const child = _child_process2.default.spawn('git', options, { cwd });
child.stdout.on('data', function (data) {return stdout += data;});
child.on('error', function () {return resolve(null);});
child.on('close', function (code) {return resolve(code === 0 ? stdout.trim() : null);});
} catch (e) {
resolve(null);
}
});
});return function getRoot(_x3) {return _ref2.apply(this, arguments);};})() };
function findChangedFiles(
cwd,
options)
{
return new Promise((resolve, reject) => {
const args = options && options.lastCommit ?
['show', '--name-only', '--pretty=%b', 'HEAD'] :
['ls-files', '--other', '--modified', '--exclude-standard'];
const child = _child_process2.default.spawn('git', args, { cwd });
let stdout = '';
let stderr = '';
child.stdout.on('data', data => stdout += data);
child.stderr.on('data', data => stderr += data);
child.on('error', e => reject(e));
child.on('close', code => {
if (code === 0) {
stdout = stdout.trim();
if (stdout === '') {
resolve([]);
} else {
resolve(
stdout.
split('\n').
map(changedPath => _path2.default.resolve(cwd, changedPath)));
}
} else {
reject(code + ': ' + stderr);
}
});
});
} /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/function isGitRepository(cwd) {return new Promise(resolve => {try {let stdout = '';const options = ['rev-parse', '--show-toplevel'];const child = _child_process2.default.spawn('git', options, { cwd });child.stdout.on('data', data => stdout += data);
child.on('error', () => resolve(null));
child.on('close', code => resolve(code === 0 ? stdout.trim() : null));
} catch (e) {
resolve(null);
}
});
}
module.exports = {
findChangedFiles,
isGitRepository };
module.exports = adapter;

@@ -13,63 +13,62 @@ 'use strict';

var _path = require('path');var _path2 = _interopRequireDefault(_path);
var _child_process = require('child_process');var _child_process2 = _interopRequireDefault(_child_process);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
var _child_process = require('child_process');var _child_process2 = _interopRequireDefault(_child_process);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};} /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const env = Object.assign({}, process.env, { HGPLAIN: 1 });const adapter = { findChangedFiles: (() => {var _ref = _asyncToGenerator(function* (cwd,
options)
{
return new Promise(function (resolve, reject) {
let args = ['status', '-amnu'];
if (options && options.withAncestor) {
args.push('--rev', 'ancestor(.^)');
} else if (options && options.lastCommit === true) {
args = ['tip', '--template', '{files%"{file}\n"}'];
}
const child = _child_process2.default.spawn('hg', args, { cwd, env });
let stdout = '';
let stderr = '';
child.stdout.on('data', function (data) {return stdout += data;});
child.stderr.on('data', function (data) {return stderr += data;});
child.on('error', function (e) {return reject(e);});
child.on('close', function (code) {
if (code === 0) {
stdout = stdout.trim();
if (stdout === '') {
resolve([]);
} else {
resolve(
stdout.
split('\n').
map(function (changedPath) {return _path2.default.resolve(cwd, changedPath);}));
const env = Object.assign({}, process.env, {
HGPLAIN: 1 }); /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/function findChangedFiles(cwd, options) {
return new Promise((resolve, reject) => {
let args = ['status', '-amn'];
if (options && options.withAncestor) {
args.push('--rev', 'ancestor(.^)');
} else if (options && options.lastCommit === true) {
args = ['tip', '--template', '{files%"{file}\n"}'];
}
const child = _child_process2.default.spawn('hg', args, { cwd, env });
let stdout = '';
let stderr = '';
child.stdout.on('data', data => stdout += data);
child.stderr.on('data', data => stderr += data);
child.on('error', e => reject(e));
child.on('close', code => {
if (code === 0) {
stdout = stdout.trim();
if (stdout === '') {
resolve([]);
} else {
resolve(
stdout.
split('\n').
map(changedPath => _path2.default.resolve(cwd, changedPath)));
}
} else {
reject(code + ': ' + stderr);
}
});
});
});return function findChangedFiles(_x, _x2) {return _ref.apply(this, arguments);};})(),
getRoot: (() => {var _ref2 = _asyncToGenerator(function* (cwd) {
return new Promise(function (resolve) {
try {
let stdout = '';
const child = _child_process2.default.spawn('hg', ['root'], { cwd, env });
child.stdout.on('data', function (data) {return stdout += data;});
child.on('error', function () {return resolve(null);});
child.on('close', function (code) {return resolve(code === 0 ? stdout.trim() : null);});
} catch (e) {
resolve(null);
}
} else {
reject(code + ': ' + stderr);
}
});
});
}
});
});return function getRoot(_x3) {return _ref2.apply(this, arguments);};})() };
function isHGRepository(cwd) {
return new Promise(resolve => {
try {
let stdout = '';
const child = _child_process2.default.spawn('hg', ['root'], { cwd, env });
child.stdout.on('data', data => stdout += data);
child.on('error', () => resolve(null));
child.on('close', code => resolve(code === 0 ? stdout.trim() : null));
} catch (e) {
resolve(null);
}
});
}
module.exports = {
findChangedFiles,
isHGRepository };
module.exports = adapter;

@@ -11,11 +11,59 @@ 'use strict';

var _git = require('./git');var _git2 = _interopRequireDefault(_git);
var _hg = require('./hg');var _hg2 = _interopRequireDefault(_hg);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/module.exports = { git: _git2.default, hg: _hg2.default };
var _hg = require('./hg');var _hg2 = _interopRequireDefault(_hg);
var _throat = require('throat');var _throat2 = _interopRequireDefault(_throat);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};} /**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/ // This is an arbitrary number. The main goal is to prevent projects with
// many roots (50+) from spawning too many processes at once.
const mutex = (0, _throat2.default)(5);const findGitRoot = dir => mutex(() => _git2.default.getRoot(dir));const findHgRoot = dir => mutex(() => _hg2.default.getRoot(dir));const getChangedFilesForRoots = (() => {var _ref = _asyncToGenerator(function* (roots,
options)
{
const repos = yield findRepos(roots);
const gitPromises = Array.from(repos.git).map(function (repo) {return (
_git2.default.findChangedFiles(repo, options));});
const hgPromises = Array.from(repos.hg).map(function (repo) {return (
_hg2.default.findChangedFiles(repo, options));});
const changedFiles = (yield Promise.all(
gitPromises.concat(hgPromises))).
reduce(function (allFiles, changedFilesInTheRepo) {
for (const file of changedFilesInTheRepo) {
allFiles.add(file);
}
return allFiles;
}, new Set());
return { changedFiles, repos };
});return function getChangedFilesForRoots(_x, _x2) {return _ref.apply(this, arguments);};})();
const findRepos = (() => {var _ref2 = _asyncToGenerator(function* (roots) {
const gitRepos = yield Promise.all(
roots.reduce(function (promises, root) {return promises.concat(findGitRoot(root));}, []));
const hgRepos = yield Promise.all(
roots.reduce(function (promises, root) {return promises.concat(findHgRoot(root));}, []));
return {
git: new Set(gitRepos.filter(Boolean)),
hg: new Set(hgRepos.filter(Boolean)) };
});return function findRepos(_x3) {return _ref2.apply(this, arguments);};})();
module.exports = {
findRepos,
getChangedFilesForRoots };
{
"name": "jest-changed-files",
"version": "20.1.0-alpha.3",
"version": "20.1.0-beta.1",
"repository": {

@@ -9,3 +9,6 @@ "type": "git",

"license": "BSD-3-Clause",
"main": "build/index.js"
"main": "build/index.js",
"dependencies": {
"throat": "^4.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc