Created
May 17, 2019 22:04
-
-
Save smcatala/9d2e2fd9d3873c901c49e5533d00c83a to your computer and use it in GitHub Desktop.
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
/** | |
* Copyright 2019 ZenyWay S.A.S., Stephane M. Catala | |
* @author Stephane M. Catala | |
* @license Apache Version 2.0 | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* Unless required by applicable law or agreed to in writing, | |
* software distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* Limitations under the License. | |
*/ | |
/** | |
* add an optional --rewrite (-r) argument that takes subarguments (see subarg module) | |
* for the connect-modrewrite middleware. | |
* other arguments are passed on unchanged to budo. | |
* eg: node budo-rw.js --rewrite ["^/some-long-hash/(:*) /$"] --live index.js | |
*/ | |
const budo = require('budo') | |
const modrewrite = require('connect-modrewrite') | |
const subarg = require('subarg') | |
const args = process.argv.slice(2) | |
const { rewrite: { _: rewriteArgs } } = subarg(args, { alias: 'r' }) | |
budo.cli(args, { | |
middleware: modrewrite(rewriteArgs) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment