Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verify if args passed with --file exists and if not show a message #4972

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/cli/collect-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const minimatch = require('minimatch');
const {NO_FILES_MATCH_PATTERN} = require('../errors').constants;
const lookupFiles = require('./lookup-files');
const {castArray} = require('../utils');
const fs = require('fs');

/**
* Exports a function that collects test files from CLI parameters.
Expand Down Expand Up @@ -49,6 +50,19 @@ module.exports = ({
}
}, []);

// resolve filepath and verify if exists
fileArgs.map(filepath => path.resolve(filepath));
var file = fs.existsSync(fileArgs);
var result = [file]
.map(function (file) {
return file ? 'File exists' : 'Cannot find test file';
})
.filter(function (file) {
return file;
});

console.log(result);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, You must get rid of the console.log and update the PR


// ensure we don't sort the stuff from fileArgs; order is important!
if (sort) {
specFiles.sort();
Expand All @@ -59,6 +73,7 @@ module.exports = ({
...fileArgs.map(filepath => path.resolve(filepath)),
...specFiles
];

debug('test files (in order): ', files);

if (!files.length) {
Expand Down