Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,19 @@ ${json.slice(0, -2)}
: undefined;
}

public updateExtensions(): void { // we cannot handle enable/disable at the moment, see <https://github.com/microsoft/vscode/issues/15466#issuecomment-724147661>
if(!files.isDirectory(this.Extensions) || !files.isFile(this.extensions)) return;

const json: string = fs.readFileSync(this.extensions, "utf-8");

const extensions: [{
public updateExtensions(json: string): void { // we cannot handle enable/disable at the moment, see <https://github.com/microsoft/vscode/issues/15466#issuecomment-724147661>
const extensions: {
identifier: string,
version: string,
enabled: boolean
}] = isValidJson(json) ? JSON.parse(json) : [];
}[] | undefined = isValidJson(json) ? JSON.parse(json) : undefined;

if(!Array.isArray(extensions) || !extensions.every(e => isNotNull(e) && typeof e.identifier === "string" && e.identifier.trim() !== ""))
return logger.warn("Skipped updating extensions: extensions.json is malformed", true);

fs.writeFileSync(this.extensions, json, {encoding: "utf-8"});

if(!files.isDirectory(this.Extensions)) return;

const installed: string[] = fs.readdirSync(this.Extensions!, {withFileTypes: true})
.filter(f => f.isDirectory())
Expand Down
8 changes: 3 additions & 5 deletions src/sync/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ export const pull: (repo: string, branch?: string, skipNotify?: boolean) => Prom
/* extensions */ {
const extensions: string = path.join(temp, "extensions.json");

if(files.isFile(extensions)){
fs.copyFileSync(extensions, dist.extensions);

dist.updateExtensions();
}else
if(files.isFile(extensions))
dist.updateExtensions(fs.readFileSync(extensions, {encoding: "utf-8"}));
else
logger.warn("Extensions not found");
}

Expand Down
8 changes: 3 additions & 5 deletions src/sync/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ export const inport: (fsPath: string) => void = (fsPath: string) => {
/* extensions */ {
const extensions: AdmZip.IZipEntry | null = zip.getEntry("extensions.json");

if(extensions && !extensions.isDirectory){
zip.extractEntryTo("extensions.json", dist.User, undefined, true);

dist.updateExtensions();
}else
if(extensions && !extensions.isDirectory)
dist.updateExtensions(extensions.getData().toString("utf-8"));
else
logger.warn("Extensions not found");
}

Expand Down
Loading