Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

jest-changed-files

Package Overview
Dependencies
Maintainers
1
Versions
187
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
13.2.2
to
13.3.0-alpha.a44f195f
+3
-2
package.json
{
"name": "jest-changed-files",
"version": "13.2.2",
"version": "13.3.0-alpha.a44f195f",
"repository": {

@@ -14,3 +14,4 @@ "type": "git",

"jest": {
"rootDir": "./build",
"rootDir": "./src",
"scriptPreprocessor": "../../babel-jest",
"testEnvironment": "node"

@@ -17,0 +18,0 @@ },

/**
* 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.
*/
'use strict';
jest.disableAutomock();
const os = require('os');
const fs = require('fs');
const path = require('path');
const rimraf = require('rimraf');
const childProcess = require('child_process');
const tmpdir = path.resolve(os.tmpdir(), 'jest-changed-files-git');
const tmpfile = path.resolve(tmpdir, Date.now() + '.js');
const tmpdirNested = path.resolve(tmpdir, 'src');
const tmpfileNested = path.resolve(tmpdirNested, Date.now() + '.js');
describe('gitChecker', () => {
let git;
beforeEach(() => {
git = require('../git');
childProcess.spawnSync('mkdir', ['-p', tmpdirNested]);});
afterEach(() => rimraf.sync(tmpdir));
describe('isGitRepository', () => {
it('returns null for non git repo folder', () => {
return git.isGitRepository(tmpdir).then(res => {
expect(res).toBeNull();});});
it('returns dirname for git repo folder', () => {
childProcess.spawnSync('git', ['init', tmpdir]);
return git.isGitRepository(tmpdir).then(res => {
expect(res).toContain(tmpdir);});});});
describe('findChangedFiles', () => {
beforeEach(() => {
childProcess.spawnSync('git', ['init', tmpdir]);});
it('returns an empty array for git repo folder without modified files', () => {
return git.findChangedFiles(tmpdir).then(res => {
expect(res).toEqual([]);});});
it('returns an array of modified files for git repo folder', () => {
fs.writeFileSync(tmpfile);
fs.writeFileSync(tmpfileNested);
return git.findChangedFiles(tmpdir).then(res => {
expect(res).toEqual([tmpfile, tmpfileNested]);});});});});
/**
* 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.
*/
'use strict';
jest.disableAutomock();
const os = require('os');
const fs = require('fs');
const path = require('path');
const rimraf = require('rimraf');
const childProcess = require('child_process');
const tmpdir = path.resolve(os.tmpdir(), 'jest-changed-files-hg');
const tmpfile = path.resolve(tmpdir, Date.now() + '.js');
const tmpdirNested = path.resolve(tmpdir, 'src');
const tmpfileNested = path.resolve(tmpdirNested, Date.now() + '.js');
describe('hgChecker', () => {
let hg;
beforeEach(() => {
hg = require('../hg');
childProcess.spawnSync('mkdir', ['-p', tmpdirNested]);});
afterEach(() => rimraf.sync(tmpdir));
describe('isHGRepository', () => {
it('returns null for non hg repo folder', () =>
hg.isHGRepository(tmpdir).then(res => {
expect(res).toBeNull();}));
it('returns dirname for hg repo folder', () => {
childProcess.spawnSync('hg', ['init', tmpdir]);
return hg.isHGRepository(tmpdir).then(res => {
expect(res).toContain(tmpdir);});});});
describe('findChangedFiles', () => {
beforeEach(() => {
childProcess.spawnSync('hg', ['init', tmpdir]);});
it('returns an empty array for hg repo folder without modified files', () =>
hg.findChangedFiles(tmpdir).then(res => {
expect(res).toEqual([]);}));
it('returns an array of modified files for hg repo folder', () => {
fs.writeFileSync(tmpfile);
fs.writeFileSync(tmpfileNested);
childProcess.spawnSync('hg', ['add'], { cwd: tmpdir });
return hg.findChangedFiles(tmpdir).then(res => {
expect(res).toEqual([tmpfile, tmpfileNested]);});});});});
/**
* 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.
*
*
*/
'use strict';
const path = require('path');
const childProcess = require('child_process');
function findChangedFiles(cwd) {
return new Promise((resolve, reject) => {
const args = ['ls-files', '--other', '--modified', '--exclude-standard'];
const child = childProcess.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 => path.resolve(cwd, changedPath)));}} else
{
reject(code + ': ' + stderr);}});});}
function isGitRepository(cwd) {
return new Promise(resolve => {
try {
let stdout = '';
const options = ['rev-parse', '--show-toplevel'];
const child = childProcess.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 = {
isGitRepository,
findChangedFiles };
/**
* 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.
*
*
*/
'use strict';
const path = require('path');
const childProcess = require('child_process');
const env = Object.assign({}, process.env, {
HGPLAIN: 1 });
function findChangedFiles(cwd, options) {
return new Promise((resolve, reject) => {
const args = ['status', '-amn'];
if (options && options.withAncestor) {
args.push('--rev', 'ancestor(.^)');}
const child = childProcess.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 => path.resolve(cwd, changedPath)));}} else
{
reject(code + ': ' + stderr);}});});}
function isHGRepository(cwd) {
return new Promise(resolve => {
try {
let stdout = '';
const child = childProcess.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 = {
isHGRepository,
findChangedFiles };
/**
* 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.
*/
'use strict';
module.exports = {
git: require('./git'),
hg: require('./hg') };

Sorry, the diff of this file is not supported yet