Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function tryGetProjectPackageVersion(resolver: EnhancedResolver, projectBasePath: string, packageName: string): Promise {
try {
let jsonPath = await resolveAsync(resolver, projectBasePath, packageName + '/package.json');
jsonPath = upath.toUnix(jsonPath);
if (jsonPath.startsWith(projectBasePath) === false) {
// explicitly prevent resolution in parent folder...
return undefined;
}
const json = await fse.readJson(jsonPath);
const version = json['version'];
return version;
} catch (error) {
return undefined;
}
}
async function tryGetProjectPackage(resolver: EnhancedResolver, projectBasePath: string, packageName: string): Promise {
try {
let modulePath = await resolveAsync(resolver, projectBasePath, packageName);
modulePath = upath.toUnix(modulePath);
if (modulePath.startsWith(projectBasePath) === false) {
// explicitly prevent resolution in parent folder...
return undefined;
}
return require(modulePath);
} catch (error) {
return undefined;
}
}
export function normalize(path) {
return upath.toUnix(path);
}
removeFile(filePath: string): boolean {
filePath = upath.toUnix(filePath);
let sourcePath = filePath;
if (filePath.endsWith('.vue')) {
sourcePath = upath.addExt(filePath, '.ts');
}
return this.sources.delete(sourcePath);
}
}
export async function readProjectSettingsFrom(folder: string): Promise {
const settings: ProjectSettings = {
root: upath.toUnix(folder),
input: 'client',
output: 'wwwroot',
jsOut: 'ipack.js',
cssOut: 'ipack.css',
alias: {},
externals: {},
copy: [],
namespace: undefined,
port1: 0,
};
const ajv = new Ajv();
const settingsJsonSchema = await fse.readJson(settingsJsonSchemaPath);
const validate = ajv.compile(settingsJsonSchema);
var downloadNextFile = function() {
if(list.files.length == 0) {
downloadingStatus.dispose();
vscode.window.setStatusBarMessage("Ftp-sync: download complete", STATUS_TIMEOUT);
}
else
{
var file = list.files[0];
list.files.splice(0, 1);
var remoteFilePath = upath.toUnix(path.join(remotePath, file.id));
var localFilePath = path.join(localPath, file.id);
mkdirp(path.dirname(localFilePath), function(err) {
ftp.get(remoteFilePath, localFilePath, function(err) {
if(err)
vscode.window.showErrorMessage("Ftp-sync: error while downloading file: " + err);
downloadingStatus.dispose();
downloadingStatus = vscode.window.setStatusBarMessage("Ftp-sync: downloaded " + (totalFiles - list.files.length) + " of " + totalFiles + " files...");
downloadNextFile();
});
});
}
}