Skip to content

Commit

Permalink
support for SOURCE_DATE_EPOCH (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored Apr 29, 2022
1 parent d97fcad commit 309e336
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h1>Options</h1>
<tr><td>status</td><td>Status of specification. Can be `proposal`, `draft`, or `standard`. Default is `proposal`.</td></tr>
<tr><td>stage</td><td>Stage of proposal. Must be a number if provided, but is optional. Sets `version` to `Stage N Draft`, but can be overridden.</td></tr>
<tr><td>version</td><td>Version of specification, for example `6&lt;sup>th&lt;/sup> Edition` or `Draft 1`. Optional.</td></tr>
<tr><td>date</td><td>Date the spec was generated. Used for various pieces of boilerplate that include dates. Defaults to today's date.</td></tr>
<tr><td>date</td><td>Date the spec was generated. Used for various pieces of boilerplate that include dates. Defaults to the value of <a href="https://reproducible-builds.org/docs/source-date-epoch/">the SOURCE_DATE_EPOCH environment variable</a> (as a number of second since the Unix epoch) if it exists, otherwise defaults to today's date.</td></tr>
<tr><td>shortname</td><td>Shortname of specification, for example `ECMA-262` or `ECMA-402`.</td></tr>
<tr><td>location</td><td>URL of this specification. Use in conjunction with the biblio file to enable external specs to reference this one.</td></tr>
<tr><td>copyright</td><td>Emit copyright and software license information. Boolean, default true.</td></tr>
Expand Down
9 changes: 9 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ const build = debounce(async function build() {
warnings.push(err);
};

if (process.env.SOURCE_DATE_EPOCH) {
const sde = process.env.SOURCE_DATE_EPOCH.trim();
if (!/^[0-9]+/.test(sde)) {
fail(`SOURCE_DATE_EPOCH value ${sde} is not valid`);
}
const ts = +sde;
opts.date = new Date(ts * 1000);
}

const spec = await ecmarkup.build(args.files[0], utils.readFile, opts);

if (args.verbose) {
Expand Down

0 comments on commit 309e336

Please sign in to comment.