Skip to content

Commit

Permalink
fix:lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kchindam-infy committed Jul 29, 2024
1 parent 9ee9bc2 commit bb2523f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const spawnWithShell = (cmd, args, opts, extra) => {
}

const options = { ...opts, shell: false }
const realArgs = []
let realArgs = []
let script = cmd

// first, determine if we're in windows because if we are we need to know if we're
Expand Down Expand Up @@ -114,11 +114,11 @@ const spawnWithShell = (cmd, args, opts, extra) => {
}
realArgs.push('/d', '/s', '/c', script)
options.windowsVerbatimArguments = true
} else if(opts.isWSL) {
//handling for WSL
script = `${cmd} ${args.join(' ')}`
realArgs = ['-Command', script]
}else {
} else if (opts.isWSL) {
// handling for WSL
script = `${cmd} ${args.join(' ')}`
realArgs = ['-Command', script]

Check warning

Code scanning / CodeQL

Unsafe shell command constructed from library input Medium

This shell argument which depends on
library input
is later used in a
shell command
.
This shell argument which depends on
library input
is later used in a
shell command
.
This shell argument which depends on
library input
is later used in a
shell command
.
This shell argument which depends on
library input
is later used in a
shell command
.
} else {
for (const arg of args) {
script += ` ${escape.sh(arg)}`
}
Expand All @@ -130,7 +130,7 @@ const spawnWithShell = (cmd, args, opts, extra) => {

// open a file with the default application as defined by the user's OS
const open = (_args, opts = {}, extra = {}) => {
const args = [].concat(_args)
let args = [].concat(_args)

let platform = process.platform
let isWSL = false
Expand All @@ -139,7 +139,7 @@ const open = (_args, opts = {}, extra = {}) => {

if (platform === 'linux') {
const osRelease = os.release().toLowerCase()
if(osRelease.includes('microsoft') || osRelease.includes('wsl')){
if (osRelease.includes('microsoft') || osRelease.includes('wsl')) {
platform = 'win32'
isWSL = true
}
Expand All @@ -155,8 +155,8 @@ const open = (_args, opts = {}, extra = {}) => {
// also, the start command accepts a title so to make sure that we don't
// accidentally interpret the first arg as the title, we stick an empty
// string immediately after the start command
if(isWSL) {
//For WSL, use wslpath to convert the path if necessary
if (isWSL) {
// For WSL, use wslpath to convert the path if necessary
command = 'powershell.exe -Command'
args.unshift('Start-Process')
args = args.map(arg => `"$(wslpath -w '${arg}')"`)
Expand Down

0 comments on commit bb2523f

Please sign in to comment.