-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from Polymer/config
Add command line flags
- Loading branch information
Showing
7 changed files
with
252 additions
and
38 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,21 @@ | ||
declare module 'command-line-args' { | ||
|
||
module commandLineArgs { | ||
|
||
interface OptionDefinition { | ||
name: string; | ||
alias?: string; | ||
type?: any; | ||
multiple?: boolean; | ||
defaultOption?: boolean; | ||
defaultValue?: any; | ||
description?: string; | ||
} | ||
|
||
} | ||
|
||
function commandLineArgs(options: OptionDefinition[], argv?: string[]) | ||
: {[name: string]: any}; | ||
|
||
export = commandLineArgs; | ||
} |
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,83 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved. | ||
* This code may only be used under the BSD style license found at | ||
* http://polymer.github.io/LICENSE.txt | ||
* The complete set of authors may be found at | ||
* http://polymer.github.io/AUTHORS.txt | ||
* The complete set of contributors may be found at | ||
* http://polymer.github.io/CONTRIBUTORS.txt | ||
* Code distributed by Google as part of the polymer project is also | ||
* subject to an additional IP rights grant found at | ||
* http://polymer.github.io/PATENTS.txt | ||
*/ | ||
|
||
import { convertPackage } from './html2js'; | ||
|
||
import commandLineArgs = require('command-line-args') | ||
|
||
const optionDefinitions: commandLineArgs.OptionDefinition[] = [ | ||
{ | ||
name: 'help', | ||
type: Boolean, | ||
description: 'Show this help message.', | ||
}, | ||
{ | ||
name: 'out', | ||
type: String, | ||
defaultValue: 'html2js_out', | ||
description: 'The directory to write converted files to.' | ||
}, | ||
{ | ||
name: 'root-module', | ||
type: String, | ||
description: 'Root namespace name to use to detect exports.' | ||
}, | ||
{ | ||
name: 'exclude', | ||
type: String, | ||
multiple: true, | ||
description: 'Exclude a file from conversion.' | ||
}, | ||
{ | ||
name: 'package-name', | ||
type: String, | ||
description: 'npm package name to use for package.json' | ||
}, | ||
{ | ||
name: 'npm-version', | ||
type: String, | ||
description: 'Version string to use for package.json' | ||
}, | ||
]; | ||
|
||
export async function run() { | ||
|
||
const options = commandLineArgs(optionDefinitions); | ||
|
||
if (options['help']) { | ||
const getUsage = require('command-line-usage'); | ||
const usage = getUsage([ | ||
{ | ||
header: 'html2js', | ||
content: 'Convert HTML Imports to JavaScript modules', | ||
}, | ||
{ | ||
header: 'Options', | ||
optionList: optionDefinitions, | ||
} | ||
]); | ||
console.log(usage); | ||
return; | ||
} | ||
|
||
await convertPackage({ | ||
outDir: options['out'], | ||
excludes: options['exclude'], | ||
rootModuleName: options['root-module'], | ||
packageName: options['package-name'], | ||
npmVersion: options['npm-version'], | ||
}); | ||
|
||
console.log('Done'); | ||
} |
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
Oops, something went wrong.