Skip to content

Commit

Permalink
Add simple greeter example to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
smrq committed Dec 1, 2015
1 parent e75bde6 commit fd1f04e
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/.*
examples/
test/
14 changes: 14 additions & 0 deletions examples/greeter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# tsify Sample: Greeter

A trivial TypeScript project building with tsify.

Based on the [TypeScript sample](https://github.com/Microsoft/TypeScriptSamples/tree/master/greeter).

## Building

Check out the scripts in `package.json` for examples on how to run a build with either the CLI or the API.

```sh
npm run build-cli
npm run build-script
```
9 changes: 9 additions & 0 deletions examples/greeter/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const browserify = require('browserify');
const tsify = require('tsify');

browserify()
.add('src/main.ts')
.plugin(tsify)
.bundle()
.on('error', function (error) { console.error(error.toString()); })
.pipe(process.stdout);
16 changes: 16 additions & 0 deletions examples/greeter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "tsify-greeter",
"version": "0.0.0",
"description": "tsify Sample: Greeter",
"scripts": {
"build-cli": "browserify -p tsify src/main.ts",
"build-script": "node ./build.js"
},
"author": "Greg Smith <[email protected]> (http://github.com/smrq)",
"license": "MIT",
"private": true,
"dependencies": {
"browserify": "*",
"tsify": "*"
}
}
6 changes: 6 additions & 0 deletions examples/greeter/src/Greeter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default class Greeter {
constructor(public greeting: string) { }
greet() {
return "<h1>" + this.greeting + "</h1>";
}
};
4 changes: 4 additions & 0 deletions examples/greeter/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Greeter from './Greeter';

const greeter = new Greeter("Hello, world!");
document.body.innerHTML = greeter.greet();

0 comments on commit fd1f04e

Please sign in to comment.