Skip to content

Commit

Permalink
Fix #646: add tools/get-filer-version.js to find old Filer versions
Browse files Browse the repository at this point in the history
  • Loading branch information
humphd committed Dec 22, 2018
1 parent 6ec8cd6 commit 7301024
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/filesystems/images/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

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.
39 changes: 39 additions & 0 deletions tools/get-filer-version.js
Original file line number Diff line number Diff line change
@@ -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});

0 comments on commit 7301024

Please sign in to comment.