Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
const absolutePath = resolvePath(nextPath);
if (!absolutePath || !await exists(absolutePath)) {
return {
value: nextPath,
isValidPath: false,
isValid: false
};
}
const dirIsValid = await isDirectory(absolutePath);
// TODO: OSX Compatibility
const files = await readdir(absolutePath);
const isValid = files.some(f => (f && f.toLowerCase()) === 'leagueclient.exe');
return {
value: isValid ? normalize(nextPath) : nextPath,
isValidPath: dirIsValid,
isValid
};
}
export function normalizePkgName(prefix: string, pkg: string) {
const normalizedPkg = normalizePath(pkg);
if (path.isAbsolute(pkg) || isRelative(pkg)) {
return normalizedPkg;
}
const parsed = parsePkg(normalizedPkg);
if (parsed.name.startsWith(prefix)) {
return normalizedPkg;
}
// need to add prefix
return parsed.scope
? `@${parsed.scope}/${prefix}-${parsed.name}`
: `${prefix}-${parsed.name}`;
}
ipcRenderer.once('app-image-uploaded', (event, data) => {
this.isEmpty = false;
this.fileName = 'media/website/' + normalizePath(data.baseImage.newPath).split('/').pop();
this.isUploading = false;
});
},
if (setting.privateKey) {
try {
connectConfig.privateKey = fse.readFileSync(setting.privateKey)
} catch (e) {
console.error('SFTP Test Remote Error: ', e.message)
result.success = false
result.message = e.message
return result
}
} else {
connectConfig.password = setting.password
}
const testFilename = 'gridea.txt'
const localTestFilePath = normalizePath(path.join(this.appDir, testFilename))
const remoteTestFilePath = normalizePath(path.join(setting.remotePath, testFilename))
try {
await client.connect(connectConfig)
await client.list('/')
try {
fse.writeFileSync(localTestFilePath, 'This is gridea test file. you can delete it.')
await client.put(localTestFilePath, remoteTestFilePath)
await client.delete(remoteTestFilePath)
} catch (e) {
console.error('SFTP Test Remote Error: ', e.message)
result.success = false
result.message = e.message
} finally {
if (fse.existsSync(localTestFilePath)) {
if (setting.privateKey) {
try {
connectConfig.privateKey = fse.readFileSync(setting.privateKey)
} catch (e) {
console.error('SFTP Test Remote Error: ', e.message)
result.success = false
result.message = e.message
return result
}
} else {
connectConfig.password = setting.password
}
const testFilename = 'gridea.txt'
const localTestFilePath = normalizePath(path.join(this.appDir, testFilename))
const remoteTestFilePath = normalizePath(path.join(setting.remotePath, testFilename))
try {
await client.connect(connectConfig)
await client.list('/')
try {
fse.writeFileSync(localTestFilePath, 'This is gridea test file. you can delete it.')
await client.put(localTestFilePath, remoteTestFilePath)
await client.delete(remoteTestFilePath)
} catch (e) {
console.error('SFTP Test Remote Error: ', e.message)
result.success = false
result.message = e.message
} finally {
export function normalizePath(inputPath) {
return normalize(path.relative('.', inputPath));
}
export function pathNormalizeToLinux(pathToNormalize?: PathOsBased): PathLinux {
return pathToNormalize ? normalize(pathToNormalize) : pathToNormalize;
}
export function pathRelativeLinux(from: PathOsBased, to: PathOsBased): PathLinux {
export function pathResolveToLinux(arr: PathOsBased[]): PathLinux {
return normalize(path.resolve(arr.join(',')));
}
addFile(file: string): void {
const normalizedFile = normalizePath(file);
this.files.push(normalizedFile);
}
drop (e) {
this.stopEvents(e);
let sourcePath = normalizePath(e.dataTransfer.files[0].path);
this.uploadImage(sourcePath);
},
remove (e) {