-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include the Zotero schema in the build. Resolve #592
Also, as part of the build, automatically fetch the latest version of the zotero-schema repo
- Loading branch information
Showing
10 changed files
with
53 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule zotero-schema
added at
a605cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import fs from "fs-extra"; | ||
import { dirname, join } from "path"; | ||
import util from "util"; | ||
import child_process from "child_process"; | ||
import { fileURLToPath } from "url"; | ||
|
||
|
||
const exec = util.promisify(child_process.exec); | ||
const ROOT = join(dirname(fileURLToPath(import.meta.url)), ".."); | ||
const modulePath = join(ROOT, "modules", "zotero-schema"); | ||
const schemaPath = join(modulePath, "schema.json"); | ||
let currentVersion = 0; | ||
|
||
try { | ||
const schema = await fs.readJson(schemaPath); | ||
currentVersion = parseInt(schema.version); | ||
} catch (e) { | ||
// ignore | ||
} | ||
|
||
(async () => { | ||
if (process.env.NODE_ENV !== 'production' || process.env.SKIP_SCHEMA_UPDATE) { | ||
console.log(`Skipping schema update check (using version ${currentVersion})`); | ||
return | ||
} | ||
try { | ||
await exec("git pull origin master --ff-only", { cwd: modulePath }); | ||
const schema = await fs.readJson(schemaPath); | ||
if (parseInt(schema.version) > currentVersion) { | ||
console.log(`Updated schema repository (${currentVersion} -> ${schema.version})`); | ||
} | ||
console.log(`Using latest schema version ${schema.version}`); | ||
} catch (e) { | ||
console.error("Failed to pull zotero-schema repository"); | ||
console.error(e); | ||
process.exit(1); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters