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

jest-changed-files

Package Overview
Dependencies
Maintainers
6
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 24.9.0 to 25.0.0

216

build/git.js

@@ -8,6 +8,6 @@ 'use strict';

function _path() {
const data = _interopRequireDefault(require('path'));
function path() {
const data = _interopRequireWildcard(require('path'));
_path = function _path() {
path = function() {
return data;

@@ -22,3 +22,3 @@ };

_execa = function _execa() {
_execa = function() {
return data;

@@ -34,129 +34,113 @@ };

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
Promise.resolve(value).then(_next, _throw);
var newObj = {};
if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc =
Object.defineProperty && Object.getOwnPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: {};
if (desc.get || desc.set) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
}
newObj.default = obj;
return newObj;
}
}
function _asyncToGenerator(fn) {
return function() {
var self = this,
args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
}
_next(undefined);
});
};
}
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
const findChangedFilesUsingCommand = async (args, cwd) => {
let result;
const findChangedFilesUsingCommand =
/*#__PURE__*/
(function() {
var _ref = _asyncToGenerator(function*(args, cwd) {
const result = yield (0, _execa().default)('git', args, {
cwd
});
return result.stdout
.split('\n')
.filter(s => s !== '')
.map(changedPath => _path().default.resolve(cwd, changedPath));
try {
result = await (0, _execa().default)('git', args, {
cwd
});
} catch (e) {
// TODO: Should we keep the original `message`?
e.message = e.stderr;
throw e;
}
return function findChangedFilesUsingCommand(_x, _x2) {
return _ref.apply(this, arguments);
};
})();
return result.stdout
.split('\n')
.filter(s => s !== '')
.map(changedPath => path().resolve(cwd, changedPath));
};
const adapter = {
findChangedFiles: (function() {
var _findChangedFiles = _asyncToGenerator(function*(cwd, options) {
const changedSince =
options && (options.withAncestor ? 'HEAD^' : options.changedSince);
const includePaths = ((options && options.includePaths) || []).map(
absoluteRoot =>
_path().default.normalize(_path().default.relative(cwd, absoluteRoot))
findChangedFiles: async (cwd, options) => {
const changedSince =
options && (options.withAncestor ? 'HEAD^' : options.changedSince);
const includePaths = ((options && options.includePaths) || []).map(
absoluteRoot => path().normalize(path().relative(cwd, absoluteRoot))
);
if (options && options.lastCommit) {
return findChangedFilesUsingCommand(
['show', '--name-only', '--pretty=format:', 'HEAD'].concat(
includePaths
),
cwd
);
if (options && options.lastCommit) {
return findChangedFilesUsingCommand(
['show', '--name-only', '--pretty=format:', 'HEAD'].concat(
includePaths
),
cwd
);
} else if (changedSince) {
const committed = yield findChangedFilesUsingCommand(
[
'log',
'--name-only',
'--pretty=format:',
'HEAD',
`^${changedSince}`
].concat(includePaths),
cwd
);
const staged = yield findChangedFilesUsingCommand(
['diff', '--cached', '--name-only'].concat(includePaths),
cwd
);
const unstaged = yield findChangedFilesUsingCommand(
['ls-files', '--other', '--modified', '--exclude-standard'].concat(
includePaths
),
cwd
);
return [...committed, ...staged, ...unstaged];
} else {
return findChangedFilesUsingCommand(
['ls-files', '--other', '--modified', '--exclude-standard'].concat(
includePaths
),
cwd
);
}
});
function findChangedFiles(_x3, _x4) {
return _findChangedFiles.apply(this, arguments);
} else if (changedSince) {
const committed = await findChangedFilesUsingCommand(
[
'log',
'--name-only',
'--pretty=format:',
'HEAD',
`^${changedSince}`
].concat(includePaths),
cwd
);
const staged = await findChangedFilesUsingCommand(
['diff', '--cached', '--name-only'].concat(includePaths),
cwd
);
const unstaged = await findChangedFilesUsingCommand(
['ls-files', '--other', '--modified', '--exclude-standard'].concat(
includePaths
),
cwd
);
return [...committed, ...staged, ...unstaged];
} else {
return findChangedFilesUsingCommand(
['ls-files', '--other', '--modified', '--exclude-standard'].concat(
includePaths
),
cwd
);
}
},
getRoot: async cwd => {
const options = ['rev-parse', '--show-cdup'];
return findChangedFiles;
})(),
getRoot: (function() {
var _getRoot = _asyncToGenerator(function*(cwd) {
const options = ['rev-parse', '--show-cdup'];
try {
const result = yield (0, _execa().default)('git', options, {
cwd
});
return _path().default.resolve(cwd, result.stdout);
} catch (e) {
return null;
}
});
function getRoot(_x5) {
return _getRoot.apply(this, arguments);
try {
const result = await (0, _execa().default)('git', options, {
cwd
});
return path().resolve(cwd, result.stdout);
} catch (e) {
return null;
}
return getRoot;
})()
}
};
var _default = adapter;
exports.default = _default;

@@ -8,6 +8,6 @@ 'use strict';

function _path() {
const data = _interopRequireDefault(require('path'));
function path() {
const data = _interopRequireWildcard(require('path'));
_path = function _path() {
path = function() {
return data;

@@ -22,3 +22,3 @@ };

_execa = function _execa() {
_execa = function() {
return data;

@@ -34,32 +34,38 @@ };

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
Promise.resolve(value).then(_next, _throw);
var newObj = {};
if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc =
Object.defineProperty && Object.getOwnPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: {};
if (desc.get || desc.set) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
}
newObj.default = obj;
return newObj;
}
}
function _asyncToGenerator(fn) {
return function() {
var self = this,
args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
}
_next(undefined);
});
};
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly)
symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}

@@ -70,13 +76,17 @@

var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(
Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
})
);
if (i % 2) {
ownKeys(source, true).forEach(function(key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(source).forEach(function(key) {
Object.defineProperty(
target,
key,
Object.getOwnPropertyDescriptor(source, key)
);
});
}
ownKeys.forEach(function(key) {
_defineProperty(target, key, source[key]);
});
}

@@ -105,53 +115,46 @@ return target;

const adapter = {
findChangedFiles: (function() {
var _findChangedFiles = _asyncToGenerator(function*(cwd, options) {
const includePaths = (options && options.includePaths) || [];
const args = ['status', '-amnu'];
findChangedFiles: async (cwd, options) => {
const includePaths = (options && options.includePaths) || [];
const args = ['status', '-amnu'];
if (options && options.withAncestor) {
args.push('--rev', `min((!public() & ::.)+.)^`);
} else if (options && options.changedSince) {
args.push('--rev', `ancestor(., ${options.changedSince})`);
} else if (options && options.lastCommit === true) {
args.push('--change', '.');
}
if (options && options.withAncestor) {
args.push('--rev', `min((!public() & ::.)+.)^`);
} else if (options && options.changedSince) {
args.push('--rev', `ancestor(., ${options.changedSince})`);
} else if (options && options.lastCommit === true) {
args.push('--change', '.');
}
args.push(...includePaths);
const result = yield (0, _execa().default)('hg', args, {
args.push(...includePaths);
let result;
try {
result = await (0, _execa().default)('hg', args, {
cwd,
env
});
return result.stdout
.split('\n')
.filter(s => s !== '')
.map(changedPath => _path().default.resolve(cwd, changedPath));
});
function findChangedFiles(_x, _x2) {
return _findChangedFiles.apply(this, arguments);
} catch (e) {
// TODO: Should we keep the original `message`?
e.message = e.stderr;
throw e;
}
return findChangedFiles;
})(),
getRoot: (function() {
var _getRoot = _asyncToGenerator(function*(cwd) {
try {
const result = yield (0, _execa().default)('hg', ['root'], {
cwd,
env
});
return result.stdout;
} catch (e) {
return null;
}
});
function getRoot(_x3) {
return _getRoot.apply(this, arguments);
return result.stdout
.split('\n')
.filter(s => s !== '')
.map(changedPath => path().resolve(cwd, changedPath));
},
getRoot: async cwd => {
try {
const result = await (0, _execa().default)('hg', ['root'], {
cwd,
env
});
return result.stdout;
} catch (e) {
return null;
}
return getRoot;
})()
}
};
var _default = adapter;
exports.default = _default;

@@ -8,3 +8,3 @@ 'use strict';

enumerable: true,
get: function get() {
get: function() {
return _types.ChangedFiles;

@@ -15,3 +15,3 @@ }

enumerable: true,
get: function get() {
get: function() {
return _types.ChangedFilesPromise;

@@ -25,3 +25,3 @@ }

_throat = function _throat() {
_throat = function() {
return data;

@@ -43,16 +43,33 @@ };

function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly)
symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(
Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
})
);
if (i % 2) {
ownKeys(source, true).forEach(function(key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(source).forEach(function(key) {
Object.defineProperty(
target,
key,
Object.getOwnPropertyDescriptor(source, key)
);
});
}
ownKeys.forEach(function(key) {
_defineProperty(target, key, source[key]);
});
}

@@ -76,34 +93,2 @@ return target;

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function() {
var self = this,
args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
}
_next(undefined);
});
};
}
function notEmpty(value) {

@@ -120,88 +105,48 @@ return value != null;

const getChangedFilesForRoots =
/*#__PURE__*/
(function() {
var _ref = _asyncToGenerator(function*(roots, options) {
const repos = yield findRepos(roots);
const getChangedFilesForRoots = async (roots, options) => {
const repos = await findRepos(roots);
const changedFilesOptions = _objectSpread(
{
includePaths: roots
},
options
);
const changedFilesOptions = _objectSpread(
{
includePaths: roots
},
options
);
const gitPromises = Array.from(repos.git).map(repo =>
_git.default.findChangedFiles(repo, changedFilesOptions)
);
const hgPromises = Array.from(repos.hg).map(repo =>
_hg.default.findChangedFiles(repo, changedFilesOptions)
);
const changedFiles = (yield Promise.all(
gitPromises.concat(hgPromises)
)).reduce((allFiles, changedFilesInTheRepo) => {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
const gitPromises = Array.from(repos.git).map(repo =>
_git.default.findChangedFiles(repo, changedFilesOptions)
);
const hgPromises = Array.from(repos.hg).map(repo =>
_hg.default.findChangedFiles(repo, changedFilesOptions)
);
const changedFiles = (await Promise.all(
gitPromises.concat(hgPromises)
)).reduce((allFiles, changedFilesInTheRepo) => {
for (const file of changedFilesInTheRepo) {
allFiles.add(file);
}
try {
for (
var _iterator = changedFilesInTheRepo[Symbol.iterator](), _step;
!(_iteratorNormalCompletion = (_step = _iterator.next()).done);
_iteratorNormalCompletion = true
) {
const file = _step.value;
allFiles.add(file);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return allFiles;
}, new Set());
return {
changedFiles,
repos
};
};
return allFiles;
}, new Set());
return {
changedFiles,
repos
};
});
return function getChangedFilesForRoots(_x, _x2) {
return _ref.apply(this, arguments);
};
})();
exports.getChangedFilesForRoots = getChangedFilesForRoots;
const findRepos =
/*#__PURE__*/
(function() {
var _ref2 = _asyncToGenerator(function*(roots) {
const gitRepos = yield Promise.all(
roots.reduce((promises, root) => promises.concat(findGitRoot(root)), [])
);
const hgRepos = yield Promise.all(
roots.reduce((promises, root) => promises.concat(findHgRoot(root)), [])
);
return {
git: new Set(gitRepos.filter(notEmpty)),
hg: new Set(hgRepos.filter(notEmpty))
};
});
const findRepos = async roots => {
const gitRepos = await Promise.all(
roots.reduce((promises, root) => promises.concat(findGitRoot(root)), [])
);
const hgRepos = await Promise.all(
roots.reduce((promises, root) => promises.concat(findHgRoot(root)), [])
);
return {
git: new Set(gitRepos.filter(notEmpty)),
hg: new Set(hgRepos.filter(notEmpty))
};
};
return function findRepos(_x3) {
return _ref2.apply(this, arguments);
};
})();
exports.findRepos = findRepos;
{
"name": "jest-changed-files",
"version": "24.9.0",
"version": "25.0.0",
"repository": {

@@ -13,11 +13,8 @@ "type": "git",

"dependencies": {
"@jest/types": "^24.9.0",
"execa": "^1.0.0",
"throat": "^4.0.0"
"@jest/types": "^25.0.0",
"execa": "^2.0.4",
"throat": "^5.0.0"
},
"devDependencies": {
"@types/execa": "^0.9.0"
},
"engines": {
"node": ">= 6"
"node": ">= 8"
},

@@ -27,3 +24,3 @@ "publishConfig": {

},
"gitHead": "9ad0f4bc6b8bdd94989804226c28c9960d9da7d1"
"gitHead": "ff9269be05fd8316e95232198fce3463bf2f270e"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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