mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
self updates are not available for windows
This commit is contained in:
parent
4d21b03ab2
commit
0b06802a3d
@ -56,30 +56,27 @@ export class UpdateCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd.self || false) {
|
if ((cmd.self || false) && process.platform !== 'win32') {
|
||||||
const zipResponse = await fetch.default(downloadUrl);
|
const zipResponse = await fetch.default(downloadUrl);
|
||||||
if (zipResponse.status === 200) {
|
if (zipResponse.status === 200) {
|
||||||
|
const currentDir = this.inPkg ? path.dirname(process.execPath) : __dirname;
|
||||||
try {
|
try {
|
||||||
const zipBuffer = await zipResponse.buffer();
|
const zipBuffer = await zipResponse.buffer();
|
||||||
const zip = new AdmZip(zipBuffer);
|
const zip = new AdmZip(zipBuffer);
|
||||||
const currentDir = this.inPkg ? path.dirname(process.execPath) : __dirname;
|
|
||||||
let currentMode: number = null;
|
let currentMode: number = null;
|
||||||
if (this.inPkg && process.platform !== 'win32') {
|
if (this.inPkg) {
|
||||||
const stats = fs.statSync(process.execPath);
|
const stats = fs.statSync(process.execPath);
|
||||||
currentMode = stats.mode;
|
currentMode = stats.mode;
|
||||||
}
|
}
|
||||||
zip.extractAllTo(currentDir, true);
|
zip.extractAllTo(currentDir, true);
|
||||||
if (process.platform !== 'win32') {
|
fs.chmodSync(path.join(currentDir, 'bw'), currentMode != null ? currentMode : '764');
|
||||||
const bwFilePath = path.join(currentDir, 'bw');
|
|
||||||
fs.chmodSync(bwFilePath, currentMode != null ? currentMode : '764');
|
|
||||||
}
|
|
||||||
res.title = 'Updated self to ' + tagName + '.';
|
res.title = 'Updated self to ' + tagName + '.';
|
||||||
if (responseJson.body != null && responseJson.body !== '') {
|
if (responseJson.body != null && responseJson.body !== '') {
|
||||||
res.message = responseJson.body;
|
res.message = responseJson.body;
|
||||||
}
|
}
|
||||||
return Response.success(res);
|
return Response.success(res);
|
||||||
} catch {
|
} catch {
|
||||||
return Response.error('Error extracting update to ' + __dirname);
|
return Response.error('Error extracting update to ' + currentDir);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Response.error('Error downloading update: ' + zipResponse.status);
|
return Response.error('Error downloading update: ' + zipResponse.status);
|
||||||
@ -96,9 +93,16 @@ export class UpdateCommand {
|
|||||||
if (responseJson.body != null && responseJson.body !== '') {
|
if (responseJson.body != null && responseJson.body !== '') {
|
||||||
res.message = responseJson.body + '\n\n';
|
res.message = responseJson.body + '\n\n';
|
||||||
}
|
}
|
||||||
res.message += 'You can download this update at: ' + downloadUrl + '\n' +
|
|
||||||
'or run `bw update --self`\n\n' +
|
res.message += 'You can download this update at ' + downloadUrl;
|
||||||
'If you installed this CLI through a package manager ' +
|
|
||||||
|
if ((cmd.self || false) && process.platform === 'win32') {
|
||||||
|
res.message += '\n`--self` updates are not available on Windows.';
|
||||||
|
} else if (process.platform !== 'win32') {
|
||||||
|
res.message += '\nor just run `bw update --self`';
|
||||||
|
}
|
||||||
|
|
||||||
|
res.message += '\n\nIf you installed this CLI through a package manager ' +
|
||||||
'you should probably update using its update command instead.';
|
'you should probably update using its update command instead.';
|
||||||
return Response.success(res);
|
return Response.success(res);
|
||||||
} else {
|
} else {
|
||||||
|
@ -474,6 +474,8 @@ export class Program {
|
|||||||
writeLn('');
|
writeLn('');
|
||||||
writeLn(' Use the `--raw` option to return only the download URL for the update.');
|
writeLn(' Use the `--raw` option to return only the download URL for the update.');
|
||||||
writeLn('');
|
writeLn('');
|
||||||
|
writeLn(' `--self` updates are not available on Windows.');
|
||||||
|
writeLn('');
|
||||||
writeLn(' Examples:');
|
writeLn(' Examples:');
|
||||||
writeLn('');
|
writeLn('');
|
||||||
writeLn(' bw update');
|
writeLn(' bw update');
|
||||||
|
Loading…
Reference in New Issue
Block a user