From 730102438297d89b18f51cbd863e0dc4a2c27e9e Mon Sep 17 00:00:00 2001 From: David Humphrey Date: Sat, 22 Dec 2018 01:02:04 -0500 Subject: [PATCH] Fix #646: add tools/get-filer-version.js to find old Filer versions --- tests/filesystems/images/README.md | 2 ++ tools/get-filer-version.js | 39 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tools/get-filer-version.js diff --git a/tests/filesystems/images/README.md b/tests/filesystems/images/README.md index 93c35b8..8958d43 100644 --- a/tests/filesystems/images/README.md +++ b/tests/filesystems/images/README.md @@ -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. diff --git a/tools/get-filer-version.js b/tools/get-filer-version.js new file mode 100644 index 0000000..b380455 --- /dev/null +++ b/tools/get-filer-version.js @@ -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 [--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});