mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-22 17:39:12 +01:00
21 lines
445 B
JavaScript
21 lines
445 B
JavaScript
export function pluginHookImport(contents) {
|
|
let parsed;
|
|
try {
|
|
parsed = JSON.parse(contents);
|
|
} catch (err) {
|
|
return undefined;
|
|
}
|
|
|
|
if (!isJSObject(parsed)) {
|
|
return undefined;
|
|
}
|
|
|
|
if (parsed.yaakSchema !== 1) return undefined;
|
|
|
|
return { resources: parsed.resources }; // Should already be in the correct format
|
|
}
|
|
|
|
export function isJSObject(obj) {
|
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
}
|