Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Add support for -spec files #6

Merged
merged 1 commit into from
Oct 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ function activate (context) {
const filenameWithoutExtension = openedFile[3]
const filenameExtension = openedFile[4]

const isSpecFile = /(\.|_)(spec|test)\./
const isSpecFile = /(\.|_|-)(spec|test)\./
if (!isSpecFile.test(openedFile)) {
const sufixSpecs = ['.spec', '.test', '_spec', '_test']
const sufixSpecs = ['.spec', '.test', '_spec', '_test', '-spec', '-test']

const sufixToOpen = sufixSpecs.map(spec => `${path}${filenameWithoutExtension}${spec}${filenameExtension}`)
.filter(spec => fs.existsSync(spec))
Expand All @@ -44,7 +44,7 @@ function activate (context) {
})
}
} else {
const sufixSpecs = ['.spec', '.test', '_spec', '_test']
const sufixSpecs = ['.spec', '.test', '_spec', '_test', '-spec', '-test']
let fileToOpen = openedFilename
sufixSpecs.forEach(spec => { fileToOpen = fileToOpen.replace(spec, '') })
if (fs.existsSync(fileToOpen)) {
Expand Down