Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
1dc8b1aeec | |||
a0c83c8f48 | |||
b6e63664bb | |||
88b39213a6 | |||
6dad1c3d85 | |||
7d9b9b2d1d |
42
README.md
42
README.md
@ -54,13 +54,17 @@ the npmts.json is the main config file. You can use it to customize the behaviou
|
||||
"ts":{
|
||||
"./customdir/*.ts":"./"
|
||||
},
|
||||
"tsconfig":true,
|
||||
"tsOptions":{
|
||||
"declaration":false,
|
||||
"target":"ES6"
|
||||
},
|
||||
"typings":[
|
||||
"./ts/typings.json",
|
||||
"./subts1/typings.json",
|
||||
"./subts2/typings.json",
|
||||
"./customdir/typings.json"
|
||||
],
|
||||
"typingsInclude":"auto",
|
||||
"codecov":true,
|
||||
"docs": {
|
||||
"publish":true
|
||||
@ -71,10 +75,10 @@ the npmts.json is the main config file. You can use it to customize the behaviou
|
||||
|
||||
| key | description |
|
||||
| --- | --- |
|
||||
| mode | "default" will do some defualt stuff, "custom" only does what you specify |
|
||||
| codecov | if true, coverage data will be uploaded to codecov when running on travis |
|
||||
| docs | `{"publish":true}` lets you control what happens with your module documentation |
|
||||
| | |
|
||||
| docs | `{"publish":true, destination:"github"}` lets you control what happens with your module documentation |
|
||||
| mode | "default" will do some defualt stuff, "custom" only does what you specify |
|
||||
| tsOptions | specify options for tsc |
|
||||
| | |
|
||||
|
||||
#### Typings
|
||||
@ -82,7 +86,8 @@ the npmts.json is the main config file. You can use it to customize the behaviou
|
||||
|
||||
> Note: You can reference the typings files in any of your TypeScript code with a
|
||||
`/// <reference path="/some/path/main.d.ts">`
|
||||
or use a tsconfig.json file.
|
||||
We are currently working on a "typingsInclude" option, that will autoload any typings during compilation.
|
||||
tsconfig is NOT supported, since it would render this module useless
|
||||
|
||||
#### TypeScript
|
||||
by default npmts looks for `./ts/*.ts` and `./test/test.ts` that will compile to
|
||||
@ -103,6 +108,8 @@ This is in line with the latest TypeScript best practices.
|
||||
You can then import plugins via the TypeScript `import` Syntax
|
||||
and tsc will pick up the declaration file automatically.
|
||||
|
||||
> Note: If you don't want declaration files, set tsOptions.declaration to false in npmts.json
|
||||
|
||||
#### Instrumentalize Code
|
||||
npmts instrumentalizes (using istanbul) the created JavaScript code to create a coverage report.
|
||||
|
||||
@ -113,30 +120,13 @@ npmts looks for `.test/test.ts` which will be transpiled to test.js and run with
|
||||
Any errors will be shown with reference to their originating source in TypeScript
|
||||
thanks to autogenerated source maps.
|
||||
|
||||
|
||||
### Custom behaviour
|
||||
Custom behaviour can be achieved through the npmts.json config file at the root of your package.
|
||||
The file must be named **npmts.json**
|
||||
|
||||
```json
|
||||
{
|
||||
"mode":"custom",
|
||||
"ts":{
|
||||
"./customdir/custom.ts":"./customcompiled.js"
|
||||
},
|
||||
"typings":[
|
||||
"./customdir"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
* **mode** can be "default" or "custom"
|
||||
* **ts** You can list as many TypeScript files as you like. The key represents the source TypeScript file, the value the output file.
|
||||
* **typings** is an array of all direcories that have a typings.json present. Uses the new typings tool from npm.
|
||||
## Example Usage in modules:
|
||||
[gulp-typings](https://www.npmjs.com/package/gulp-typings)
|
||||
[gulp-browser](https://www.npmjs.com/package/gulp-typings)
|
||||
|
||||
> We will add more options over time.
|
||||
|
||||
### About the authors:
|
||||
## About the authors:
|
||||
[](https://lossless.com/)
|
||||
|
||||
[](https://paypal.me/lossless)
|
7
dist/npmts.compile.js
vendored
7
dist/npmts.compile.js
vendored
@ -38,6 +38,13 @@ exports.run = function (configArg) {
|
||||
moduleStream.on("queueDrain", function () {
|
||||
plugins.beautylog.ok("TypeScript has been compiled!");
|
||||
moduleStream.on("finish", function () {
|
||||
try {
|
||||
if (config.mode = "default")
|
||||
plugins.fs.copySync(plugins.path.join(paths.cwd, "ts/typings"), plugins.path.join(paths.cwd, "dist/typings"));
|
||||
}
|
||||
catch (err) {
|
||||
plugins.beautylog.warn("failed to copy external typings for full module declaration support");
|
||||
}
|
||||
done.resolve(config);
|
||||
});
|
||||
moduleStream.end();
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "npmts",
|
||||
"version": "5.1.0",
|
||||
"version": "5.1.3",
|
||||
"description": "write npm modules with TypeScript",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
@ -45,6 +45,15 @@ export let run = function (configArg) {
|
||||
moduleStream.on("queueDrain", function () {
|
||||
plugins.beautylog.ok("TypeScript has been compiled!");
|
||||
moduleStream.on("finish", function () {
|
||||
try {
|
||||
if(config.mode = "default") plugins.fs.copySync(
|
||||
plugins.path.join(paths.cwd,"ts/typings"),
|
||||
plugins.path.join(paths.cwd,"dist/typings")
|
||||
);
|
||||
}
|
||||
catch (err){
|
||||
plugins.beautylog.warn("failed to copy external typings for full module declaration support");
|
||||
}
|
||||
done.resolve(config);
|
||||
});
|
||||
moduleStream.end();
|
||||
|
Reference in New Issue
Block a user