Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for SOURCE_DATE_EPOCH #440

Merged
merged 2 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
ljharb marked this conversation as resolved.
Show resolved Hide resolved
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