jest-changed-files
Advanced tools
+3
-2
| { | ||
| "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]);});});});}); |
-62
| /** | ||
| * 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 }; |
-71
| /** | ||
| * 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
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
-100%1
-75%496
-93.85%2
-71.43%0
-100%2
100%