This repository has been archived by the owner on Jul 16, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(browserSync): add proxy with browsersync
- Loading branch information
Travis CI
authored and
nicolas.martin
committed
Mar 8, 2018
1 parent
ec8de6c
commit c5a22a0
Showing
10 changed files
with
6,158 additions
and
392 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,59 @@ | ||
#!/usr/bin/env node | ||
|
||
|
||
const inquirer = require('inquirer'); | ||
const commander = require('commander'); | ||
const log = require('fancy-log'); | ||
const proxyServer = require('../src/proxy-server'); | ||
const config = require('../src/config'); | ||
|
||
commander | ||
.alias('nsc proxy-server') | ||
.option('--local <locale>', 'Load a snippet for a given localization') | ||
.parse(process.argv); | ||
|
||
runInteractive(commander); | ||
|
||
function runInteractive(options) { | ||
let questions; | ||
|
||
if (config.proxyUrls.length) { | ||
questions = [ { | ||
type: 'list', | ||
name: 'proxyUrl', | ||
message: 'Which url do you want to proxify ? ', | ||
choices: config.proxyUrls.concat([ new inquirer.Separator(), 'Enter new url' ]), | ||
required: true | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'proxyUrl', | ||
when: (answers) => answers.proxyUrl === 'Enter new url', | ||
message: 'Which url do you want to proxify ? ', | ||
default: config.siteUrl, | ||
required: true | ||
} | ||
]; | ||
} else { | ||
questions = [ { | ||
type: 'input', | ||
name: 'proxyUrl', | ||
message: 'Which url do you want to proxify ? ', | ||
default: config.siteUrl, | ||
required: true | ||
} ]; | ||
} | ||
|
||
|
||
return inquirer | ||
.prompt(questions) | ||
.then((answers) => { | ||
config.pushProxyUrl(answers.proxyUrl); | ||
|
||
proxyServer({ | ||
url: answers.proxyUrl, | ||
local: options.local | ||
}); | ||
}) | ||
.catch(er => log.error(er)); | ||
} |
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
Oops, something went wrong.