Skip to content

Commit

Permalink
fix(cli): use path.join when concatenating paths (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Feb 10, 2020
1 parent 03b557f commit 4fa9090
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion packages/lockfile-lint/__tests__/cli.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use strict'

const path = require('path')
// eslint-disable-next-line security/detect-child-process
const childProcess = require('child_process')
const cliExecPath = `${__dirname}/../bin/lockfile-lint.js`
const cliExecPath = path.join(__dirname, '../bin/lockfile-lint.js')

describe('CLI tests', () => {
test('Running without parameters should display help', done => {
Expand Down
21 changes: 11 additions & 10 deletions packages/lockfile-lint/__tests__/main.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict'

const path = require('path')
const main = require('../src/main')

describe('Main CLI logic', () => {
describe('Invoking validators should handle errors and defaults', () => {
test('when no validator function is provided expect to fail', () => {
const lockfilePath = `${__dirname}/fixtures/yarn-only-http.lock`
const lockfilePath = path.join(__dirname, '/fixtures/yarn-only-http.lock')
const lockfileType = 'yarn'
const validators = [
{
Expand Down Expand Up @@ -34,7 +35,7 @@ describe('Main CLI logic', () => {

describe('validateHttp', () => {
test('a failing validator should return proper validation failed object', () => {
const lockfilePath = `${__dirname}/fixtures/yarn-only-http.lock`
const lockfilePath = path.join(__dirname, '/fixtures/yarn-only-http.lock')
const lockfileType = 'yarn'
const validators = [
{
Expand All @@ -55,7 +56,7 @@ describe('Main CLI logic', () => {
})

test('a successful validator should return proper validation object', () => {
const lockfilePath = `${__dirname}/fixtures/yarn-only-https.lock`
const lockfilePath = path.join(__dirname, '/fixtures/yarn-only-https.lock')
const lockfileType = 'yarn'
const validators = [
{
Expand All @@ -78,7 +79,7 @@ describe('Main CLI logic', () => {

describe('validateHosts', () => {
test('a failing validator should return proper validation failed object', () => {
const lockfilePath = `${__dirname}/fixtures/yarn-only-https.lock`
const lockfilePath = path.join(__dirname, '/fixtures/yarn-only-https.lock')
const lockfileType = 'yarn'
const validators = [
{
Expand All @@ -99,7 +100,7 @@ describe('Main CLI logic', () => {
})

test('a failing validator should throw an error if an empty host is not allowed', () => {
const lockfilePath = `${__dirname}/fixtures/package-lock-empty-hostname.json`
const lockfilePath = path.join(__dirname, '/fixtures/package-lock-empty-hostname.json')
const lockfileType = 'npm'
const validators = [
{
Expand All @@ -123,7 +124,7 @@ describe('Main CLI logic', () => {
})

test('a successful validator should return proper validation object', () => {
const lockfilePath = `${__dirname}/fixtures/yarn-only-https.lock`
const lockfilePath = path.join(__dirname, '/fixtures/yarn-only-https.lock')
const lockfileType = 'yarn'
const validators = [
{
Expand All @@ -146,7 +147,7 @@ describe('Main CLI logic', () => {

describe('validateSchemes', () => {
test('should fail validating allowed schemes for a package-lock.json file', () => {
const lockfilePath = `${__dirname}/fixtures/package-lock-git-scheme.json`
const lockfilePath = path.join(__dirname, '/fixtures/package-lock-git-scheme.json')
const lockfileType = 'npm'
const validators = [
{
Expand All @@ -167,7 +168,7 @@ describe('Main CLI logic', () => {
})

test('should succeed validating allowed schemes for a package-lock.json file', () => {
const lockfilePath = `${__dirname}/fixtures/package-lock-git-scheme.json`
const lockfilePath = path.join(__dirname, '/fixtures/package-lock-git-scheme.json')
const lockfileType = 'npm'
const validators = [
{
Expand All @@ -188,7 +189,7 @@ describe('Main CLI logic', () => {
})

test('should fail validating allowed schemes for a yarn.lock file', () => {
const lockfilePath = `${__dirname}/fixtures/yarn-lock-schemes.lock`
const lockfilePath = path.join(__dirname, '/fixtures/yarn-lock-schemes.lock')
const lockfileType = 'yarn'
const validators = [
{
Expand All @@ -209,7 +210,7 @@ describe('Main CLI logic', () => {
})

test('should succeed validating allowed schemes for a yarn.lock file', () => {
const lockfilePath = `${__dirname}/fixtures/yarn-lock-schemes.lock`
const lockfilePath = path.join(__dirname, '/fixtures/yarn-lock-schemes.lock')
const lockfileType = 'yarn'
const validators = [
{
Expand Down

0 comments on commit 4fa9090

Please sign in to comment.