Skip to content

Commit

Permalink
Upgrade to OpenStreetMap Community Index 4 (#470)
Browse files Browse the repository at this point in the history
* Update package.json

* Update render.js

* Update build-resource.js

* Update package.json

* Update Resource.svelte
  • Loading branch information
jbelien authored May 14, 2021
1 parent c30299f commit b709484
Show file tree
Hide file tree
Showing 5 changed files with 607 additions and 397 deletions.
11 changes: 11 additions & 0 deletions build-resource.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
const cldr = require("cldr");
const fs = require("fs");
const glob = require("glob");
const resolveStrings = require("osm-community-index/lib/resolve_strings");
const path = require("path");

const defaultsContent = fs.readFileSync("node_modules/osm-community-index/defaults.json", "utf8");
const defaults = JSON.parse(defaultsContent);

glob
.sync("node_modules/osm-community-index/resources/**/*", {})
.filter((path) => fs.lstatSync(path).isDirectory())
Expand Down Expand Up @@ -32,6 +36,13 @@ glob
return { code, name: cldr.extractLanguageDisplayNames("en")[code] };
});
}

const resolvedStrings = resolveStrings(resource, defaults.defaults);
if (!resolvedStrings.name) { throw new Error('Cannot resolve a value for name'); }
if (!resolvedStrings.description) { throw new Error('Cannot resolve a value for description'); }
if (!resolvedStrings.url) { throw new Error('Cannot resolve a value for url'); }

resource.resolved = resolvedStrings;
});

if (array.length > 0) {
Expand Down
Loading

0 comments on commit b709484

Please sign in to comment.