diff --git a/spec/index.html b/spec/index.html index a1230511..1d8777f4 100644 --- a/spec/index.html +++ b/spec/index.html @@ -64,7 +64,7 @@

Options

statusStatus of specification. Can be `proposal`, `draft`, or `standard`. Default is `proposal`. stageStage of proposal. Must be a number if provided, but is optional. Sets `version` to `Stage N Draft`, but can be overridden. versionVersion of specification, for example `6<sup>th</sup> Edition` or `Draft 1`. Optional. - dateDate the spec was generated. Used for various pieces of boilerplate that include dates. Defaults to today's date. + dateDate the spec was generated. Used for various pieces of boilerplate that include dates. Defaults to the value of the SOURCE_DATE_EPOCH environment variable (as a number of second since the Unix epoch) if it exists, otherwise defaults to today's date. shortnameShortname of specification, for example `ECMA-262` or `ECMA-402`. locationURL of this specification. Use in conjunction with the biblio file to enable external specs to reference this one. copyrightEmit copyright and software license information. Boolean, default true. diff --git a/src/cli.ts b/src/cli.ts index 89ba0f43..503b2aa6 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -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) {