Skip to content

Commit 23013fb

Browse files
authored
add no-sandbox shortcut cmd for win(#135) (#160)
1 parent 295b466 commit 23013fb

File tree

2 files changed

+44
-15
lines changed

2 files changed

+44
-15
lines changed

gulpfile.js

+31-15
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ const gulp = require("gulp"),
66
createDMG = require('electron-installer-dmg'),
77
archiver = require('archiver'),
88
fs = require("fs"),
9+
path = require("path"),
910
pkg = require("./package");
1011

1112
const NAME = 'Kodo Browser';
1213
const KICK_NAME = 'kodo-browser';
1314
const VERSION = pkg.version;
1415
const ELECTRON_VERSION = "18.3.3";
1516
const ROOT = __dirname;
17+
// https://github.com/qiniu/kodo-browser/issues/135
18+
const WIN_NO_SANDBOX_NAME = "no-sandbox-shortcut.cmd";
1619
const BRAND = `${ROOT}/src/renderer/static/brand`;
1720
const DIST = `${ROOT}/dist`;
1821
const TARGET = `${ROOT}/build`;
@@ -59,8 +62,8 @@ gulp.task("mac", done => {
5962

6063
gulp.task("maczip", done => {
6164
console.log(`--package ${KICK_NAME}-darwin-x64-v${VERSION}.zip`);
62-
var outputZip = fs.createWriteStream(`${TARGET}/${KICK_NAME}-darwin-x64-v${VERSION}.zip`);
63-
var archive = archiver('zip', { zlib: { level: 9 } });
65+
const outputZip = fs.createWriteStream(`${TARGET}/${KICK_NAME}-darwin-x64-v${VERSION}.zip`);
66+
const archive = archiver('zip', { zlib: { level: 9 } });
6467
archive.on('error', (err) => { throw err; });
6568
archive.pipe(outputZip);
6669
archive.directory(`${TARGET}/${NAME}-darwin-x64/${NAME}.app`, `${NAME}.app`);
@@ -92,14 +95,19 @@ gulp.task("dmg", done => {
9295

9396
gulp.task("win64", done => {
9497
console.log(`--package ${NAME}-win32-x64`);
98+
const targetDir = path.resolve(TARGET, `./${NAME}-win32-x64`);
9599

96-
plugins.run(`rm -rf ${TARGET}/${NAME}-win32-x64`).exec(() => {
100+
plugins.run(`rm -rf ${targetDir}`).exec(() => {
97101
let options = Object.assign({}, packagerOptions);
98102
options.platform = "win32";
99103
options.arch = "x64";
100104
options.icon = `${BRAND}/qiniu.png`;
101105

102106
packager(options).then((paths) => {
107+
fs.copyFileSync(
108+
path.resolve(ROOT, `./${WIN_NO_SANDBOX_NAME}`),
109+
path.resolve(targetDir, `./${WIN_NO_SANDBOX_NAME}`)
110+
);
103111
console.log("--done");
104112
done();
105113
}, (errs) => {
@@ -110,24 +118,30 @@ gulp.task("win64", done => {
110118

111119
gulp.task("win64zip", done => {
112120
console.log(`--package ${KICK_NAME}-win32-x64-v${VERSION}.zip`);
113-
var outputZip = fs.createWriteStream(`${TARGET}/${KICK_NAME}-win32-x64-v${VERSION}.zip`);
114-
var archive = archiver('zip', { zlib: { level: 9 } });
121+
const inputDir = `${TARGET}/${NAME}-win32-x64`;
122+
const outputZip = fs.createWriteStream(`${TARGET}/${KICK_NAME}-win32-x64-v${VERSION}.zip`);
123+
const archive = archiver('zip', { zlib: { level: 9 } });
115124
archive.on('error', (err) => { throw err; });
116125
archive.pipe(outputZip);
117-
archive.directory(`${TARGET}/${NAME}-win32-x64`, false);
126+
archive.directory(inputDir, false);
118127
archive.finalize().then(done);
119128
});
120129

121130
gulp.task("win32", done => {
122131
console.log(`--package ${NAME}-win32-ia32`);
132+
const targetDir = path.resolve(TARGET, `./${NAME}-win32-ia32`);
123133

124-
plugins.run(`rm -rf ${TARGET}/${NAME}-win32-ia32`).exec(() => {
134+
plugins.run(`rm -rf ${targetDir}`).exec(() => {
125135
let options = Object.assign({}, packagerOptions);
126136
options.platform = "win32";
127137
options.arch = "ia32";
128138
options.icon = `${BRAND}/qiniu.png`;
129139

130140
packager(options).then((paths) => {
141+
fs.copyFileSync(
142+
path.resolve(ROOT, `./${WIN_NO_SANDBOX_NAME}`),
143+
path.resolve(targetDir, `./${WIN_NO_SANDBOX_NAME}`)
144+
);
131145
console.log("--done");
132146
done();
133147
}, (errs) => {
@@ -138,11 +152,12 @@ gulp.task("win32", done => {
138152

139153
gulp.task("win32zip", done => {
140154
console.log(`--package ${KICK_NAME}-win32-x86-v${VERSION}.zip`);
141-
var outputZip = fs.createWriteStream(`${TARGET}/${KICK_NAME}-win32-x86-v${VERSION}.zip`);
142-
var archive = archiver('zip', { zlib: { level: 9 } });
155+
const inputDir = `${TARGET}/${NAME}-win32-ia32`;
156+
const outputZip = fs.createWriteStream(`${TARGET}/${KICK_NAME}-win32-x86-v${VERSION}.zip`);
157+
const archive = archiver('zip', { zlib: { level: 9 } });
143158
archive.on('error', (err) => { throw err; });
144159
archive.pipe(outputZip);
145-
archive.directory(`${TARGET}/${NAME}-win32-ia32`, false);
160+
archive.directory(inputDir, false);
146161
archive.finalize().then(done);
147162
});
148163

@@ -165,8 +180,8 @@ gulp.task("linux64", done => {
165180

166181
gulp.task("linux64zip", done => {
167182
console.log(`--package ${KICK_NAME}-linux-x64-v${VERSION}.zip`);
168-
var outputZip = fs.createWriteStream(`${TARGET}/${KICK_NAME}-linux-x64-v${VERSION}.zip`);
169-
var archive = archiver('zip', { zlib: { level: 9 } });
183+
const outputZip = fs.createWriteStream(`${TARGET}/${KICK_NAME}-linux-x64-v${VERSION}.zip`);
184+
const archive = archiver('zip', { zlib: { level: 9 } });
170185
archive.on('error', (err) => { throw err; });
171186
archive.pipe(outputZip);
172187
archive.directory(`${TARGET}/${NAME}-linux-x64`, false);
@@ -192,10 +207,11 @@ gulp.task("linux32", done => {
192207

193208
gulp.task("linux32zip", done => {
194209
console.log(`--package ${KICK_NAME}-linux-x86-v${VERSION}.zip`);
195-
var outputZip = fs.createWriteStream(`${TARGET}/${KICK_NAME}-linux-x86-v${VERSION}.zip`);
196-
var archive = archiver('zip', { zlib: { level: 9 } });
210+
const inputDir = `${TARGET}/${NAME}-linux-ia32`;
211+
const outputZip = fs.createWriteStream(`${TARGET}/${KICK_NAME}-linux-x86-v${VERSION}.zip`);
212+
const archive = archiver('zip', { zlib: { level: 9 } });
197213
archive.on('error', (err) => { throw err; });
198214
archive.pipe(outputZip);
199-
archive.directory(`${TARGET}/${NAME}-linux-ia32`, false);
215+
archive.directory(inputDir, false);
200216
archive.finalize().then(done);
201217
});

no-sandbox-shortcut.cmd

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@echo off
2+
setlocal
3+
4+
set "script_dir=%~dp0"
5+
6+
echo Set oShell = CreateObject("WScript.Shell") > %temp%\shortcut.vbs
7+
echo sLinkFile = "%userprofile%\Desktop\Kodo Browser(no sandbox).lnk" >> %temp%\shortcut.vbs
8+
echo Set oLink = oShell.CreateShortcut(sLinkFile) >> %temp%\shortcut.vbs
9+
echo oLink.TargetPath = "%script_dir%\Kodo Browser.exe" >> %temp%\shortcut.vbs
10+
echo oLink.Arguments = "--no-sandbox" >> %temp%\shortcut.vbs
11+
echo oLink.Save >> %temp%\shortcut.vbs
12+
cscript //nologo %temp%\shortcut.vbs "%script_dir%"
13+
del %temp%\shortcut.vbs

0 commit comments

Comments
 (0)