-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #646: add tools/get-filer-version.js to find old Filer versions
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}); |