You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-24 23:26:50 +02:00
Mobile: Fixed mobile build
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs-extra');
|
||||
const shim = require('./shim').default;
|
||||
const { GeolocationNode } = require('./geolocation-node.js');
|
||||
@ -23,6 +25,15 @@ function fileExists(filePath) {
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/sindresorhus/callsites/blob/main/index.js
|
||||
function callsites() {
|
||||
const _prepareStackTrace = Error.prepareStackTrace;
|
||||
Error.prepareStackTrace = (_any, stack) => stack;
|
||||
const stack = new Error().stack.slice(1);
|
||||
Error.prepareStackTrace = _prepareStackTrace;
|
||||
return stack;
|
||||
}
|
||||
|
||||
const gunzipFile = function(source, destination) {
|
||||
if (!fileExists(source)) {
|
||||
throw new Error(`No such file: ${source}`);
|
||||
@ -535,7 +546,17 @@ function shimInit(sharp = null, keytar = null, React = null) {
|
||||
};
|
||||
|
||||
shim.requireDynamic = (path) => {
|
||||
return require(path);
|
||||
if (path.indexOf('.') === 0) {
|
||||
const sites = callsites();
|
||||
if (sites.length <= 1) throw new Error(`Cannot require file (1) ${path}`);
|
||||
const filename = sites[1].getFileName();
|
||||
if (!filename) throw new Error(`Cannot require file (2) ${path}`);
|
||||
|
||||
const fileDirName = require('path').dirname(filename);
|
||||
return require(`${fileDirName}/${path}`);
|
||||
} else {
|
||||
return require(path);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user