Skip to content

Commit 0a414c6

Browse files
author
Joel Denning
authored
Default manifestFile to "importmap" (#169)
1 parent d8e9678 commit 0a414c6

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Here are the properties available in the config file:
9696

9797
- `urlSafeList` (optional, but **highly** recommended): An array of strings and/or functions that indicate which URLs are trusted when updating the import map. A string value is treated as a URL prefix - for example `https://unpkg.com/`. A function value is called with a [URL object](https://developer.mozilla.org/en-US/docs/Web/API/URL) and must return a truthy value when the URL is trusted. Any attempt to update the import map to include an untrusted URL will be rejected. If you omit `urlSafeList`, all URLs are considered trusted (not recommended).
9898
- `packagesViaTrailingSlashes` (optional, defaults to true): A boolean that indicates whether to turn off the automatic generation of trailing slash package records on PATCH service requests. For more information and examples visit [standard guideline](https://github.com/WICG/import-maps/#packages-via-trailing-slashes).
99-
- `manifestFormat` (required): A string that is either `"importmap"` or `"sofe"`, which indicates whether the import-map-deployer is
99+
- `manifestFormat` (optional, defaults to `"importmap"`): A string that is either `"importmap"` or `"sofe"`. Sofe is for legacy use.
100100
interacting with an [import map](https://github.com/WICG/import-maps) or a [sofe manifest](https://github.com/CanopyTax/sofe).
101101
- `locations` (required): An object specifying one or more "locations" (or "environments") for which you want the import-map-deployer to control the import map. The special `default`
102102
location is what will be used when no query parameter `?env=` is provided in calls to the import-map-deployer. If no `default` is provided, the import-map-deployer will create

src/config.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ const fs = require("fs"),
33
path = require("path"),
44
argv = require("minimist")(process.argv.slice(2));
55

6+
const defaultConfig = {
7+
manifestFormat: "importmap",
8+
};
9+
610
if (argv._.length > 1)
711
throw new Error(
8-
`sofe-deplanifester expects only a single argument, which is the configuration file`
12+
`import-map-deployer expects only a single argument, which is the configuration file`
913
);
1014

1115
let config = {};
@@ -20,5 +24,14 @@ if (argv._.length === 0) {
2024
}
2125
}
2226

23-
exports.setConfig = (newConfig) => (config = newConfig);
27+
config = applyDefaults(config);
28+
29+
exports.setConfig = (newConfig) => (config = applyDefaults(newConfig));
2430
exports.getConfig = () => config;
31+
32+
function applyDefaults(config) {
33+
return {
34+
...defaultConfig,
35+
...config,
36+
};
37+
}

0 commit comments

Comments
 (0)