Fix #646: add tools/get-filer-version.js to find old Filer versions

This commit is contained in:
David Humphrey 2018-12-22 01:02:04 -05:00
parent 6ec8cd6191
commit 7301024382
2 changed files with 41 additions and 0 deletions

View File

@ -5,3 +5,5 @@ generate them:
1. `tiny-fs.0.43.json` was created from `tests/filesystem/tiny-fs/` with https://github.com/filerjs/filer/blob/d66114e20c7f0235698d9933dbd90217ba86fa4e/dist/filer.min.js 1. `tiny-fs.0.43.json` was created from `tests/filesystem/tiny-fs/` with https://github.com/filerjs/filer/blob/d66114e20c7f0235698d9933dbd90217ba86fa4e/dist/filer.min.js
If you need to create a new image, use `tools/get-filer-version.js` to
get a specific version of Filer, then `tools/fs-image.js` to generate an image.

View File

@ -0,0 +1,39 @@
#!/usr/bin/env node
/* eslint-disable no-console */
'use strict';
const {spawn} = require('child_process');
const meow = require('meow');
const cli = meow(`
Usage
$ get-filer-version <SHA|branch|tag> [--out path/to/filer.js]
Options
--out, -o Specify a Filer module path to use for output
Examples
$ get-filer-version v0.0.44
$ get-filer-version v0.0.44 --out filer.js
`, {
description: 'Try to get an old version of Filer based on git SHA, branch, or tag',
flags: {
out: {
type: 'string',
alias: 'o'
}
}
});
// Get arg list, make sure we get a SHA argument
cli.flags.app = cli.input.slice(1);
if(!(cli.input && cli.input.length === 1)) {
console.error('Specify a git SHA, branch or tag to use');
process.exit(1);
}
const sha = cli.input[0];
const out = cli.flags.out || `filer-${sha}.js`;
// https://stackoverflow.com/questions/888414/git-checkout-older-revision-of-a-file-under-a-new-name?answertab=active#tab-top
const cmd = `git show ${sha}:dist/filer.js > ${out}`;
spawn (cmd, [], {stdio: 'inherit', shell: true});