Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Commit

Permalink
Merge pull request #150 from Polymer/init
Browse files Browse the repository at this point in the history
Fixups for github hosted templates
  • Loading branch information
justinfagnani committed May 17, 2016
2 parents 0ee46db + 4b5ac98 commit f028cbc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
18 changes: 10 additions & 8 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,24 @@ export class InitCommand implements Command {
let templateDescriptions = {
'application': "Application-style project",
'element': "Reusable element-style project",
'shop': "shop demo app",
'prpl-demo': "PRPL demo app",
'shop': "The Shop PRPL demo application",
'app-drawer-template':
"Application template that demonstrates the PRPL pattern",
};

env.registerStub(ElementGenerator, 'polymer-init-element:app');
env.registerStub(ApplicationGenerator, 'polymer-init-application:app');
let shopGenerator = createGithubGenerator({
owner: 'PolymerLabs',
repo: 'polykart',
owner: 'Polymer',
repo: 'shop',
});
env.registerStub(shopGenerator, 'polymer-init-shop:app');
let prplGenerator = createGithubGenerator({
owner: 'PolymerLabs',
repo: 'prpl-demo',
let appDrawerGenerator = createGithubGenerator({
owner: 'Polymer',
repo: 'app-drawer-template',
});
env.registerStub(prplGenerator, 'polymer-init-prpl-demo:app');
env.registerStub(appDrawerGenerator,
'polymer-init-app-drawer-template:app');

env.lookup(() => {
let generators = env.getGeneratorsMeta();
Expand Down
17 changes: 11 additions & 6 deletions src/github/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ export class Github {
private _repo: string;

static tokenFromFile(filename: string): string {
return fs.readFileSync(filename, 'utf8').trim();
try {
return fs.readFileSync(filename, 'utf8').trim();
} catch (e) {
return null;
}
}


constructor(opts: GithubOpts) {
this._token = opts.githubToken || Github.tokenFromFile('token');
this._owner = opts.owner;
Expand All @@ -44,10 +47,12 @@ export class Github {
version: '3.0.0',
protocol: 'https',
});
this._github.authenticate({
type: 'oauth',
token: this._token,
});
if (this._token != null) {
this._github.authenticate({
type: 'oauth',
token: this._token,
});
}
this._request = opts.requestApi || request;
}

Expand Down
4 changes: 3 additions & 1 deletion src/init/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export function createGithubGenerator(githubOptions: GithubGeneratorOptions) {
}

install() {
this.installDependencies();
this.installDependencies({
npm: false,
});
}
}
}

0 comments on commit f028cbc

Please sign in to comment.