You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
All: Added script to build welcome assets and to import them on startup
This commit is contained in:
@ -101,7 +101,7 @@ function shimInit() {
|
||||
}
|
||||
}
|
||||
|
||||
shim.createResourceFromPath = async function(filePath) {
|
||||
shim.createResourceFromPath = async function(filePath, defaultProps = null) {
|
||||
const readChunk = require('read-chunk');
|
||||
const imageType = require('image-type');
|
||||
|
||||
@ -111,8 +111,12 @@ function shimInit() {
|
||||
|
||||
if (!(await fs.pathExists(filePath))) throw new Error(_('Cannot access %s', filePath));
|
||||
|
||||
defaultProps = defaultProps ? defaultProps : {};
|
||||
|
||||
const resourceId = defaultProps.id ? defaultProps.id : uuid.create();
|
||||
|
||||
let resource = Resource.new();
|
||||
resource.id = uuid.create();
|
||||
resource.id = resourceId;
|
||||
resource.mime = mime.getType(filePath);
|
||||
resource.title = basename(filePath);
|
||||
|
||||
@ -143,6 +147,10 @@ function shimInit() {
|
||||
await fs.copy(filePath, targetPath, { overwrite: true });
|
||||
}
|
||||
|
||||
if (defaultProps) {
|
||||
resource = Object.assign({}, resource, defaultProps);
|
||||
}
|
||||
|
||||
return await Resource.save(resource, { isNew: true });
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user