Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.findExecutable = (command, cwd, options) => {
// If we have an absolute path then we take it.
if (path.isAbsolute(command)) {
return command
}
let dir = path.dirname(command)
if (dir !== '.') {
// We have a directory and the directory is relative (see above). Make the path absolute
// to the current working directory.
return path.join(cwd, command)
}
let paths
// The options can override the PATH. So consider that PATH if present.
if (options && options.env) {
// Path can be named in many different ways and for the execution it doesn't matter
for (let key of Object.keys(options.env)) {
if (key.toLowerCase() === 'path') {
if (typeof options.env[key] === 'string') {
paths = options.env[key].split(path.delimiter)
linkClicked(text: string, dir: string) {
const { file, line = 1, column = 0 } = parseGoPosition(text)
let filepath
if (path.isAbsolute(file)) {
filepath = file
} else {
const base = dir || projectPath()
if (!base) {
return
}
filepath = path.join(base, file)
}
const col = column && column > 0 ? column - 1 : 0
openFile(filepath, { row: line - 1, column: col }).catch(err => {
console.log('could not access ' + file, err) // eslint-disable-line no-console
})
}
private fixHref(resource: vscode.Uri, href: string): string {
if (!href) {
return href;
}
// Use href if it is already an URL
const hrefUri = vscode.Uri.parse(href);
if (['http', 'https'].indexOf(hrefUri.scheme) >= 0) {
return hrefUri.toString();
}
// Use href as file URI if it is absolute
if (path.isAbsolute(href) || hrefUri.scheme === 'file') {
return vscode.Uri.file(href)
.with({ scheme: 'vscode-resource' })
.toString();
}
// Use a workspace relative path if there is a workspace
let root = vscode.workspace.getWorkspaceFolder(resource);
if (root) {
return vscode.Uri.file(path.join(root.uri.fsPath, href))
.with({ scheme: 'vscode-resource' })
.toString();
}
// Otherwise look relative to the asciidoc file
return vscode.Uri.file(path.join(path.dirname(resource.fsPath), href))
.with({ scheme: 'vscode-resource' })
public constructor(private directory: string) {
// If the directory path is not absolute, make it so
if (!path.isAbsolute(directory)) {
this.directory = path.join(process.cwd(), this.directory);
}
}
devtoolModuleFilenameTemplate: (info /*: Object */) => {
// always return absolute paths in order to get sensible source map explorer visualization
return path.isAbsolute(info.absoluteResourcePath)
? info.absoluteResourcePath
: path.join(dir, info.absoluteResourcePath);
},
},
async ({path, run, source}) => {
await run(`install`);
const {stdout} = await run(`bin`, `has-bin-entries`);
expect(isAbsolute(stdout.trim())).toEqual(true);
},
),
const cb = () => {
if (!path.extname(filePath)) {
filePath += `.${this.ext}`;
}
return path.isAbsolute(filePath)
? filePath
: path.resolve(this.baseDir, filePath);
};
function normalizeWatchFilePath (filepath, baseDir) {
const { isAbsolute, relative } = require('path')
if (isAbsolute(filepath)) {
return relative(baseDir, filepath)
}
return filepath
}
Module._findPath = function(request, paths, isMain) {
if (path.isAbsolute(request) ||
'/__enclose_io_memfs__' == request.substring(0, '/__enclose_io_memfs__'.length) ||
'\\__enclose_io_memfs__' == request.substring(0, '\\__enclose_io_memfs__'.length)) {
paths = [''];
} else if (!paths || paths.length === 0) {
return false;
}
const cacheKey = JSON.stringify({request: request, paths: paths});
if (Module._pathCache[cacheKey]) {
return Module._pathCache[cacheKey];
}
var exts;
const trailingSlash = request.length > 0 &&
request.charCodeAt(request.length - 1) === 47/*/*/;