mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-19 11:09:03 +00:00
refactor code insertion to avoid duplication
This commit is contained in:
parent
07b1726ac1
commit
7082899f86
15
pkg/apply.js
15
pkg/apply.js
@ -128,7 +128,7 @@ module.exports = async function ({ overwrite_version, friendly_errors } = {}) {
|
|||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
fs.writeFile(
|
fs.writeFile(
|
||||||
insertion_file,
|
insertion_file,
|
||||||
`${data
|
data
|
||||||
.replace(
|
.replace(
|
||||||
/process.platform === "win32"/g,
|
/process.platform === "win32"/g,
|
||||||
'process.platform === "win32" || process.platform === "linux"'
|
'process.platform === "win32" || process.platform === "linux"'
|
||||||
@ -136,21 +136,18 @@ module.exports = async function ({ overwrite_version, friendly_errors } = {}) {
|
|||||||
.replace(
|
.replace(
|
||||||
/else \{[\s\n]+const win = createWindow_1\.createWindow\(relativeUrl\);/g,
|
/else \{[\s\n]+const win = createWindow_1\.createWindow\(relativeUrl\);/g,
|
||||||
'else if (relativeUrl) { const win = createWindow_1.createWindow(relativeUrl);'
|
'else if (relativeUrl) { const win = createWindow_1.createWindow(relativeUrl);'
|
||||||
)}\n\n//notion-enhancer\nrequire('${realpath(
|
),
|
||||||
__dirname
|
|
||||||
)}/loader.js')(__filename, exports);`,
|
|
||||||
'utf8',
|
'utf8',
|
||||||
(err) => {
|
(err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
fs.appendFile(
|
|
||||||
insertion_file,
|
|
||||||
`\n\n//notion-enhancer\nrequire('notion-enhancer/pkg/loader.js')(__filename, exports);`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
fs.appendFile(
|
||||||
|
insertion_file,
|
||||||
|
`\n\n//notion-enhancer\nrequire('notion-enhancer/pkg/loader.js')(__filename, exports);`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// not resolved, nothing else in apply process depends on it
|
// not resolved, nothing else in apply process depends on it
|
||||||
|
Loading…
Reference in New Issue
Block a user