Compare commits
52 Commits
Author | SHA1 | Date | |
---|---|---|---|
7a26721420 | |||
0dc307f082 | |||
4b2c0fe461 | |||
50fd5e83ad | |||
3e55a666b2 | |||
5d8ce3f227 | |||
de4bbaed9f | |||
7d18e92ff1 | |||
634763c03f | |||
3352165436 | |||
6c57a4703f | |||
822734e545 | |||
8dcbe98c60 | |||
2fbcb58078 | |||
362f8d5388 | |||
8fb4a60fb3 | |||
7c6b5afd5f | |||
f83eb035c2 | |||
359e844c69 | |||
6b40cfd954 | |||
8f13dbef9f | |||
9ff2453d7b | |||
e40a82e8c9 | |||
cac50f7099 | |||
ef64874411 | |||
870d24701c | |||
d12a09d3d8 | |||
2a4811ccb0 | |||
146b9cf683 | |||
9110a6701d | |||
3101af3726 | |||
20283c6cda | |||
814542e9cd | |||
bea8a50f0b | |||
d18dc73522 | |||
6bf81fc665 | |||
a9a23687e9 | |||
e50a86439b | |||
ee69817038 | |||
ef314f5b2d | |||
24f9e5e982 | |||
660942e798 | |||
f5bc4578d7 | |||
2a87fc839d | |||
149e0cbc9e | |||
3b69350ce2 | |||
ea793f9556 | |||
5266fcd3df | |||
39b7fe99c7 | |||
e1419d85cc | |||
71f8d14ee9 | |||
d539aef414 |
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,3 +1,7 @@
|
|||||||
.idea/
|
.idea/
|
||||||
.c9/
|
.c9/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
test/**/node_modules/
|
||||||
|
test/**/typings/
|
||||||
|
ts/*.js
|
||||||
|
ts/*.js.map
|
@ -1,5 +1,6 @@
|
|||||||
|
.idea/
|
||||||
support
|
support
|
||||||
compile
|
compile
|
||||||
test
|
test/
|
||||||
examples
|
examples
|
||||||
.gitignore
|
.gitignore
|
11
.travis.yml
Normal file
11
.travis.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- "4.2.4"
|
||||||
|
deploy:
|
||||||
|
provider: npm
|
||||||
|
email: npm@lossless.digital
|
||||||
|
api_key:
|
||||||
|
secure: k075QdAcmEdmAoVaP5vclLnZmhbZB39v85VIUMWAKXbIAU+liHrYZRlIEYfAaIUrf6sha+zAo/U/vjAN7c5ArB7J/HjCLJ3lsi2fWtaSRlYQrYX9/EhU0S+YZjRE8Jrn4hGTcce6I2mANBnEzvzlXrlKaqVvSqOqTO9nJ5aDBCGa5XT3EwlHKkRlAlL3ZOLrRg38R343E8ifZBsbn9G0e+RgDt0sic3WD8NME9lpsQ/99UZKH00duHbhF9nme5Sjdh86y01hvsaBf+CLR4gfS2IntnrCSrZbETFrsOBUyMnJZDQ3qlrjcEaiTkpJ4iSIqr+ftwGMMD6S1MxCTPqkp64UIeMz2Tg41HqoaeIg7z8cF0APv6M9ZAdWhsU43GqsMe70dK900JZpQAkQxMf/6NpPpGfZug6TwqLYSIRzvjvNrhYfuyoGfXdAxrM3SJMkIq6rwE+T/y36kZaC3CrQRyNZypNz0vW1M9HLjJUi2vO0U/CDn8tvi1p6ChrDXDfV3H2UIAMHFlAF+GrT7dMWwD+p+d8mc9gpAFEF9zMqAIJamPhwboJxoHjKQrqrq5czNm75ETL77AzfnU6CfQlG5dTIFnGId8y0ZxXvtpBruDoyC1+ZF23MYZmb+ipxQZM2oLCjNLeL3aEePc/JlSm6Gn8w3sIkZTG261F0XZxdApw=
|
||||||
|
on:
|
||||||
|
tags: true
|
||||||
|
repo: pushrocks/npmts
|
1
README-dev.md
Normal file
1
README-dev.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# README-dev
|
60
README.md
Normal file
60
README.md
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# npmts
|
||||||
|
Write npm modules with TypeScript without hassle.
|
||||||
|
|
||||||
|
## How to use npmts
|
||||||
|
|
||||||
|
### Install
|
||||||
|
First install npmts as dev dependency:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install npmts --save-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Then use it in package.json's script section to trigger a build:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"scripts": {
|
||||||
|
"test": "npmts"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Default behaviour
|
||||||
|
by default npmts looks for `./ts/index.ts` and `./ts/test.ts` that will compile to
|
||||||
|
`./index.js` and `./test.js`
|
||||||
|
|
||||||
|
#### Declaration files
|
||||||
|
**npmts** also creates an `index.d.ts` declaration file by default.
|
||||||
|
You can reference it in your package.json like this:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"main": "index.js",
|
||||||
|
"typings": "./index.d.ts",
|
||||||
|
```
|
||||||
|
|
||||||
|
When requiring the module from other TypeScript files,
|
||||||
|
the TypeScript Compiler will use the declaration file to resolve typings.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Custom behaviour
|
||||||
|
NPMTS looks for an npmts.json at the root of your package.
|
||||||
|
|
||||||
|
```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.
|
||||||
|
|
||||||
|
## Readme for Devs
|
||||||
|
There is a [README-dev.md](README-dev.md) in the repo.
|
||||||
|
This is only of interest for you when looking to contribute to, improve or build upon this package.
|
@ -1,25 +1,35 @@
|
|||||||
// import gulp
|
// import gulp
|
||||||
var gulp = require("gulp");
|
|
||||||
var gulpTypescript = require("gulp-typescript");
|
|
||||||
var gulpInsert = require("gulp-insert");
|
|
||||||
var plugins = {
|
var plugins = {
|
||||||
beautylog: require("beautylog")
|
beautylog: require("beautylog"),
|
||||||
|
gulp: require("gulp"),
|
||||||
|
g:{
|
||||||
|
typescript: require("gulp-typescript"),
|
||||||
|
insert: require("gulp-insert")
|
||||||
|
},
|
||||||
|
mergeStream: require("merge2")
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
plugins.beautylog.log('now compiling the mojo.io gulp tasks');
|
|
||||||
|
|
||||||
gulp.task('indexTS', function() {
|
plugins.beautylog.log('now compiling NPMTS');
|
||||||
var stream = gulp.src('../ts/index.ts')
|
|
||||||
.pipe(gulpTypescript({
|
plugins.gulp.task('indexTS', function() {
|
||||||
out: "index.js"
|
var tsResult = plugins.gulp.src('../ts/index.ts')
|
||||||
}))
|
.pipe(plugins.g.typescript({
|
||||||
.pipe(gulpInsert.prepend('#!/usr/bin/env node\n\n'))
|
out:"index.js",
|
||||||
.pipe(gulp.dest("../"));
|
declaration:true
|
||||||
return stream;
|
}));
|
||||||
|
|
||||||
|
return plugins.mergeStream([
|
||||||
|
tsResult.dts.pipe(plugins.gulp.dest('../')),
|
||||||
|
tsResult.js
|
||||||
|
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
|
||||||
|
.pipe(plugins.gulp.dest('../'))
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('default',['indexTS'], function() {
|
plugins.gulp.task('default',['indexTS'], function() {
|
||||||
plugins.beautylog.success('Typescript compiled');
|
plugins.beautylog.success('Typescript compiled');
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.start.apply(gulp, ['default']);
|
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
60
index.d.ts
vendored
Normal file
60
index.d.ts
vendored
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
|
declare module NpmtsPlugins {
|
||||||
|
var init: () => {
|
||||||
|
beautylog: any;
|
||||||
|
fs: any;
|
||||||
|
gulp: any;
|
||||||
|
g: {
|
||||||
|
insert: any;
|
||||||
|
sequence: any;
|
||||||
|
typescript: any;
|
||||||
|
};
|
||||||
|
mathjs: any;
|
||||||
|
mergeStream: any;
|
||||||
|
mocha: any;
|
||||||
|
path: any;
|
||||||
|
q: any;
|
||||||
|
smartcli: any;
|
||||||
|
smartfile: any;
|
||||||
|
typings: any;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
declare module NpmtsPaths {
|
||||||
|
var init: () => any;
|
||||||
|
}
|
||||||
|
declare module NpmtsOptions {
|
||||||
|
var config: any;
|
||||||
|
var run: () => any;
|
||||||
|
}
|
||||||
|
declare module NpmtsCustom {
|
||||||
|
var run: () => any;
|
||||||
|
}
|
||||||
|
declare module NpmtsDefault {
|
||||||
|
var run: () => any;
|
||||||
|
}
|
||||||
|
declare module NpmtsTests {
|
||||||
|
var run: () => any;
|
||||||
|
}
|
||||||
|
declare module NpmtsPromisechain {
|
||||||
|
var init: () => any;
|
||||||
|
}
|
||||||
|
declare var plugins: {
|
||||||
|
beautylog: any;
|
||||||
|
fs: any;
|
||||||
|
gulp: any;
|
||||||
|
g: {
|
||||||
|
insert: any;
|
||||||
|
sequence: any;
|
||||||
|
typescript: any;
|
||||||
|
};
|
||||||
|
mathjs: any;
|
||||||
|
mergeStream: any;
|
||||||
|
mocha: any;
|
||||||
|
path: any;
|
||||||
|
q: any;
|
||||||
|
smartcli: any;
|
||||||
|
smartfile: any;
|
||||||
|
typings: any;
|
||||||
|
};
|
||||||
|
declare var paths: any;
|
||||||
|
declare var promisechain: any;
|
288
index.js
288
index.js
@ -1,28 +1,264 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./index.ts" />
|
||||||
var plugins = {
|
var NpmtsPlugins;
|
||||||
beautylog: require("beautylog"),
|
(function (NpmtsPlugins) {
|
||||||
gulp: require("gulp"),
|
NpmtsPlugins.init = function () {
|
||||||
gulpTypeScript: require("gulp-typescript"),
|
var plugins = {
|
||||||
path: require("path"),
|
beautylog: require("beautylog"),
|
||||||
smartcli: require("smartcli")
|
fs: require("fs-extra"),
|
||||||
};
|
gulp: require("gulp"),
|
||||||
var paths = {};
|
g: {
|
||||||
paths.cwd = plugins.smartcli.get.cwd().path;
|
insert: require("gulp-insert"),
|
||||||
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
|
sequence: require("gulp-sequence"),
|
||||||
paths.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
|
typescript: require("gulp-typescript")
|
||||||
plugins.gulp.task("indexTS", function () {
|
},
|
||||||
plugins.gulp.src(paths.indexTS)
|
mathjs: require("mathjs"),
|
||||||
.pipe(plugins.gulpTypeScript({
|
mergeStream: require("merge2"),
|
||||||
out: "index.js"
|
mocha: require("mocha"),
|
||||||
}))
|
path: require("path"),
|
||||||
.pipe(plugins.gulp.dest(paths.cwd));
|
q: require("q"),
|
||||||
});
|
smartcli: require("smartcli"),
|
||||||
plugins.gulp.task("indexTS", function () {
|
smartfile: require("smartfile"),
|
||||||
plugins.gulp.src(paths.indexTS)
|
typings: require("typings")
|
||||||
.pipe(plugins.gulpTypeScript({
|
};
|
||||||
out: "test.js"
|
return plugins;
|
||||||
}))
|
};
|
||||||
.pipe(plugins.gulp.dest(paths.cwd));
|
})(NpmtsPlugins || (NpmtsPlugins = {}));
|
||||||
});
|
/// <reference path="./index.ts" />
|
||||||
|
/// <reference path="./index.ts" />
|
||||||
|
var NpmtsPaths;
|
||||||
|
(function (NpmtsPaths) {
|
||||||
|
NpmtsPaths.init = function () {
|
||||||
|
var paths = {};
|
||||||
|
paths.cwd = plugins.smartcli.get.cwd().path;
|
||||||
|
paths.tsDir = plugins.path.join(paths.cwd, "ts/");
|
||||||
|
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
|
||||||
|
paths.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
|
||||||
|
paths.testDir = plugins.path.join(paths.cwd, "test/");
|
||||||
|
return paths;
|
||||||
|
};
|
||||||
|
})(NpmtsPaths || (NpmtsPaths = {}));
|
||||||
|
/// <reference path="./index.ts" />
|
||||||
|
var NpmtsOptions;
|
||||||
|
(function (NpmtsOptions) {
|
||||||
|
NpmtsOptions.config = {};
|
||||||
|
NpmtsOptions.run = function () {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
var configPath = plugins.path.join(paths.cwd, "npmts.json");
|
||||||
|
if (plugins.smartfile.checks.fileExistsSync(configPath)) {
|
||||||
|
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
||||||
|
NpmtsOptions.config = plugins.smartfile.readFileToObject(configPath);
|
||||||
|
switch (NpmtsOptions.config.mode) {
|
||||||
|
case "default":
|
||||||
|
plugins.beautylog.log("mode is " + NpmtsOptions.config.mode.yellow);
|
||||||
|
done.resolve();
|
||||||
|
break;
|
||||||
|
case "custom":
|
||||||
|
plugins.beautylog.log("mode is " + NpmtsOptions.config.mode.yellow);
|
||||||
|
done.resolve();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
plugins.beautylog.error("mode " + NpmtsOptions.config.mode.yellow + " not recognised!".red);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
||||||
|
NpmtsOptions.config.mode = "default";
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
;
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
})(NpmtsOptions || (NpmtsOptions = {}));
|
||||||
|
/// <reference path="./index.ts" />
|
||||||
|
var NpmtsCustom;
|
||||||
|
(function (NpmtsCustom) {
|
||||||
|
NpmtsCustom.run = function () {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
var config = NpmtsOptions.config;
|
||||||
|
if (config.mode === "custom") {
|
||||||
|
plugins.beautylog.log("now running custom tasks");
|
||||||
|
var moduleStream = plugins.mergeStream({ end: false });
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- first install typings ---------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
var typingsDone = plugins.q.defer();
|
||||||
|
var typingsCounter = 0;
|
||||||
|
var typingsCounterAdvance = function () {
|
||||||
|
typingsCounter++;
|
||||||
|
if (typeof config.typings[typingsCounter] != "undefined") {
|
||||||
|
installTypings();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugins.beautylog.success("custom typings installed successfully");
|
||||||
|
typingsDone.resolve();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var installTypings = function () {
|
||||||
|
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue);
|
||||||
|
plugins.typings.install({ production: false, cwd: plugins.path.join(paths.cwd, config.typings[typingsCounter]) })
|
||||||
|
.then(function () {
|
||||||
|
typingsCounterAdvance();
|
||||||
|
}, function () {
|
||||||
|
plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue);
|
||||||
|
typingsCounterAdvance();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
installTypings();
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- second compile TS -------------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
typingsDone.promise.then(function () {
|
||||||
|
for (var key in config.ts) {
|
||||||
|
plugins.beautylog.log("now compiling" + key.blue);
|
||||||
|
var outputPathIsDir;
|
||||||
|
try {
|
||||||
|
if (plugins.fs.statSync(plugins.path.join(paths.cwd, config.ts[key])).isDirectory()) {
|
||||||
|
outputPathIsDir = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
outputPathIsDir = false;
|
||||||
|
}
|
||||||
|
//do some evaluation of the environment
|
||||||
|
var outputNameSpecified = (!outputPathIsDir
|
||||||
|
&& (plugins.path.extname(config.ts[key]) == ".js"));
|
||||||
|
console.log("outputNameSpecified");
|
||||||
|
var outputName = (function () {
|
||||||
|
if (outputNameSpecified) {
|
||||||
|
return plugins.path.basename(config.ts[key]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
var outputDir = (function () {
|
||||||
|
if (outputNameSpecified) {
|
||||||
|
return plugins.path.dirname(plugins.path.join(paths.cwd, config.ts[key]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return plugins.path.join(paths.cwd, config.ts[key]);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd, key))
|
||||||
|
.pipe(plugins.g.typescript({
|
||||||
|
out: outputName,
|
||||||
|
declaration: true
|
||||||
|
}));
|
||||||
|
var stream = plugins.mergeStream([
|
||||||
|
tsStream.dts.pipe(plugins.gulp.dest(outputDir)),
|
||||||
|
tsStream.js
|
||||||
|
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
|
||||||
|
.pipe(plugins.gulp.dest(outputDir))
|
||||||
|
]);
|
||||||
|
moduleStream.add(stream);
|
||||||
|
}
|
||||||
|
moduleStream.on("queueDrain", function () {
|
||||||
|
plugins.beautylog.success("custom TypeScript installed successfully");
|
||||||
|
moduleStream.on("finish", function () {
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
moduleStream.end();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
})(NpmtsCustom || (NpmtsCustom = {}));
|
||||||
|
/// <reference path="./index.ts" />
|
||||||
|
var NpmtsDefault;
|
||||||
|
(function (NpmtsDefault) {
|
||||||
|
NpmtsDefault.run = function () {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
plugins.gulp.task("defaultTypings", function (cb) {
|
||||||
|
plugins.beautylog.log("now installing default typings");
|
||||||
|
plugins.typings.install({ production: false, cwd: paths.tsDir })
|
||||||
|
.then(function () {
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
plugins.gulp.task("defaultIndexTS", function () {
|
||||||
|
plugins.beautylog.log("now compiling" + " ts/index.ts".blue);
|
||||||
|
var tsResult = plugins.gulp.src(paths.indexTS)
|
||||||
|
.pipe(plugins.g.typescript({
|
||||||
|
out: "./index.js",
|
||||||
|
declaration: true
|
||||||
|
}));
|
||||||
|
return plugins.mergeStream([
|
||||||
|
tsResult.dts.pipe(plugins.gulp.dest(paths.cwd)),
|
||||||
|
tsResult.js
|
||||||
|
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
|
||||||
|
.pipe(plugins.gulp.dest(paths.cwd))
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
plugins.gulp.task("defaultTestTS", function () {
|
||||||
|
plugins.beautylog.log("now compiling" + " ts/test.ts".blue);
|
||||||
|
var stream = plugins.gulp.src(paths.testTS)
|
||||||
|
.pipe(plugins.g.typescript({
|
||||||
|
out: "test.js"
|
||||||
|
}))
|
||||||
|
.pipe(plugins.gulp.dest(paths.testDir));
|
||||||
|
return stream;
|
||||||
|
});
|
||||||
|
plugins.gulp.task("defaultCleanup", function (cb) {
|
||||||
|
plugins.beautylog.success("default TypeScript for this module compiled successfully.");
|
||||||
|
done.resolve();
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
plugins.gulp.task("default", function (cb) {
|
||||||
|
if (NpmtsOptions.config.mode == "default") {
|
||||||
|
plugins.g.sequence("defaultTypings", "defaultIndexTS", "defaultTestTS", "defaultCleanup", cb);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cb();
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
})(NpmtsDefault || (NpmtsDefault = {}));
|
||||||
|
/// <reference path="./index.ts" />
|
||||||
|
var NpmtsTests;
|
||||||
|
(function (NpmtsTests) {
|
||||||
|
NpmtsTests.run = function () {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
plugins.fs.ensureDirSync(paths.testDir); //make sure that mocha has a directory to look for tests
|
||||||
|
plugins.beautylog.info("Now running mocha tests");
|
||||||
|
var mocha = new plugins.mocha(); // Instantiate a Mocha instance.
|
||||||
|
mocha.addFile(plugins.path.join(paths.testDir, "test.js"));
|
||||||
|
mocha.run(function (failures) {
|
||||||
|
process.on('exit', function () {
|
||||||
|
process.exit(failures);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
})(NpmtsTests || (NpmtsTests = {}));
|
||||||
|
/// <reference path="./index.ts" />
|
||||||
|
var NpmtsPromisechain;
|
||||||
|
(function (NpmtsPromisechain) {
|
||||||
|
NpmtsPromisechain.init = function () {
|
||||||
|
var promisechain;
|
||||||
|
NpmtsOptions.run()
|
||||||
|
.then(NpmtsDefault.run)
|
||||||
|
.then(NpmtsCustom.run)
|
||||||
|
.then(NpmtsTests.run);
|
||||||
|
return promisechain;
|
||||||
|
};
|
||||||
|
})(NpmtsPromisechain || (NpmtsPromisechain = {}));
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
/// <reference path="./npmts.plugins.ts" />
|
||||||
|
/// <reference path="./npmts.cli.ts" />
|
||||||
|
/// <reference path="./npmts.paths.ts" />
|
||||||
|
/// <reference path="./npmts.options.ts" />
|
||||||
|
/// <reference path="./npmts.custom.ts" />
|
||||||
|
/// <reference path="./npmts.default.ts" />
|
||||||
|
/// <reference path="./npmts.tests.ts" />
|
||||||
|
/// <reference path="./npmts.promisechain.ts" />
|
||||||
|
console.log("**** starting NPMTS ****");
|
||||||
|
var plugins = NpmtsPlugins.init();
|
||||||
|
var paths = NpmtsPaths.init();
|
||||||
|
var promisechain = NpmtsPromisechain.init();
|
||||||
|
28
package.json
28
package.json
@ -1,14 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "npmts",
|
"name": "npmts",
|
||||||
"version": "0.0.3",
|
"version": "2.1.2",
|
||||||
"description": "write npm modules with TypeScript",
|
"description": "write npm modules with TypeScript",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
"typings": "./index.d.ts",
|
||||||
"bin": {
|
"bin": {
|
||||||
"npmts": "index.js"
|
"npmts": "./index.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(cd compile && node compile.js)",
|
"test": "(cd compile && node compile.js) && (cd test/assets && node ../../index.js)",
|
||||||
"testm": "(cd test/ && npm update && npm test)"
|
"release": "(git add -A && git commit -m 'update' && git push origin master && npm version patch && npm publish)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -25,10 +26,19 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/npmts#readme",
|
"homepage": "https://github.com/pushrocks/npmts#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "^2.0.2",
|
"beautylog": "2.0.7",
|
||||||
"gulp": "^3.9.0",
|
"fs-extra": "^0.26.5",
|
||||||
"gulp-insert": "^0.5.0",
|
"gulp": "3.9.0",
|
||||||
"gulp-typescript": "^2.10.0",
|
"gulp-insert": "0.5.0",
|
||||||
"smartcli": "0.0.11"
|
"gulp-sequence": "^0.4.4",
|
||||||
|
"gulp-typescript": "2.10.0",
|
||||||
|
"gulp-typings": "0.0.0",
|
||||||
|
"mathjs": "^2.7.0",
|
||||||
|
"merge2": "1.0.1",
|
||||||
|
"mocha": "^2.4.5",
|
||||||
|
"q": "^1.4.1",
|
||||||
|
"smartcli": "0.0.11",
|
||||||
|
"smartfile": "0.0.11",
|
||||||
|
"typings": "^0.6.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
test/assets/custom.d.ts
vendored
Normal file
1
test/assets/custom.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
declare var hello: string;
|
3
test/assets/custom.js
Normal file
3
test/assets/custom.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var hello = "hello";
|
2
test/assets/customdir/custom.js
Normal file
2
test/assets/customdir/custom.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var hello = "hello";
|
||||||
|
//# sourceMappingURL=custom.js.map
|
1
test/assets/customdir/custom.js.map
Normal file
1
test/assets/customdir/custom.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"custom.js","sourceRoot":"","sources":["custom.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,OAAO,CAAC"}
|
1
test/assets/customdir/custom.ts
Normal file
1
test/assets/customdir/custom.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
var hello = "hello";
|
2
test/assets/customdir/tsfile1.js
Normal file
2
test/assets/customdir/tsfile1.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var something = "something";
|
||||||
|
//# sourceMappingURL=tsfile1.js.map
|
1
test/assets/customdir/tsfile1.js.map
Normal file
1
test/assets/customdir/tsfile1.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"tsfile1.js","sourceRoot":"","sources":["tsfile1.ts"],"names":[],"mappings":"AAAA,IAAI,SAAS,GAAG,WAAW,CAAC"}
|
1
test/assets/customdir/tsfile1.ts
Normal file
1
test/assets/customdir/tsfile1.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
var something = "something";
|
7
test/assets/customdir/typings.json
Normal file
7
test/assets/customdir/typings.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
||||||
|
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
||||||
|
}
|
||||||
|
}
|
0
test/assets/index.d.ts
vendored
Normal file
0
test/assets/index.d.ts
vendored
Normal file
5
test/assets/index.js
Normal file
5
test/assets/index.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
console.log("test");
|
||||||
|
}());
|
12
test/assets/npmts.json
Normal file
12
test/assets/npmts.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"mode":"custom",
|
||||||
|
"ts":{
|
||||||
|
"./customdir/*.ts":"./"
|
||||||
|
},
|
||||||
|
"typings":[
|
||||||
|
"./ts",
|
||||||
|
"./subts1/",
|
||||||
|
"./subts2/",
|
||||||
|
"./customdir"
|
||||||
|
]
|
||||||
|
}
|
@ -9,6 +9,5 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"npmts": "*"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
7
test/assets/subts1/typings.json
Normal file
7
test/assets/subts1/typings.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
||||||
|
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
||||||
|
}
|
||||||
|
}
|
1
test/assets/test/test.js
Normal file
1
test/assets/test/test.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
console.log("**** starting test ****");
|
2
test/assets/ts/test.js
Normal file
2
test/assets/ts/test.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
console.log("**** starting test ****");
|
||||||
|
//# sourceMappingURL=test.js.map
|
1
test/assets/ts/test.js.map
Normal file
1
test/assets/ts/test.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC"}
|
1
test/assets/ts/test.ts
Normal file
1
test/assets/ts/test.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
console.log("**** starting test ****");
|
7
test/assets/ts/typings.json
Normal file
7
test/assets/ts/typings.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
||||||
|
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
||||||
|
}
|
||||||
|
}
|
1
test/assets/tsfile1.d.ts
vendored
Normal file
1
test/assets/tsfile1.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
declare var something: string;
|
3
test/assets/tsfile1.js
Normal file
3
test/assets/tsfile1.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var something = "something";
|
21
test/node_modules/npmts/LICENSE
generated
vendored
21
test/node_modules/npmts/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2016 Push.Rocks
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
40
test/node_modules/npmts/package.json
generated
vendored
40
test/node_modules/npmts/package.json
generated
vendored
@ -1,40 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "npmts",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"description": "write npm modules with TypeScript",
|
|
||||||
"main": "index.js",
|
|
||||||
"bin": {
|
|
||||||
"npmts": "index.js"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "(cd compile && node compile.js)"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/pushrocks/npmts.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"TypeScript",
|
|
||||||
"Declaration"
|
|
||||||
],
|
|
||||||
"author": {
|
|
||||||
"name": "Lossless Digital UG",
|
|
||||||
"url": "haftungsbeschraenkt"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/pushrocks/npmts/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/pushrocks/npmts#readme",
|
|
||||||
"dependencies": {
|
|
||||||
"beautylog": "^2.0.2",
|
|
||||||
"gulp": "^3.9.0",
|
|
||||||
"gulp-typescript": "^2.10.0",
|
|
||||||
"smartcli": "0.0.11"
|
|
||||||
},
|
|
||||||
"gitHead": "7410d22fc4ed6f9756c2b5e1e883f1d06765258e",
|
|
||||||
"readme": "ERROR: No README data found!",
|
|
||||||
"_id": "npmts@0.0.1",
|
|
||||||
"_shasum": "e2b1edfcf5093f9f3ded25cd5430732e4a128221",
|
|
||||||
"_from": "npmts@0.0.1"
|
|
||||||
}
|
|
27
ts/index.js
27
ts/index.js
@ -1,27 +0,0 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
gulp: require("gulp"),
|
|
||||||
gulpTypeScript: require("gulp-typescript"),
|
|
||||||
path: require("path"),
|
|
||||||
smartcli: require("smartcli")
|
|
||||||
};
|
|
||||||
var paths = {};
|
|
||||||
paths.cwd = plugins.smartcli.get.cwd().path;
|
|
||||||
paths.indexTS = plugins.path.join(paths.cwd, "ts/index.ts");
|
|
||||||
paths.testTS = plugins.path.join(paths.cwd, "ts/test.ts");
|
|
||||||
plugins.gulp.task("indexTS", function () {
|
|
||||||
plugins.gulp.src(paths.indexTS)
|
|
||||||
.pipe(plugins.gulpTypeScript({
|
|
||||||
out: "index.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd));
|
|
||||||
});
|
|
||||||
plugins.gulp.task("indexTS", function () {
|
|
||||||
plugins.gulp.src(paths.indexTS)
|
|
||||||
.pipe(plugins.gulpTypeScript({
|
|
||||||
out: "test.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd));
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,IAAI,OAAO,GAAG;IACV,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC,iBAAiB,CAAC;IAC1C,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC;CAChC,CAAC;AAEF,IAAI,KAAK,GAAO,EAAE,CAAC;AACnB,KAAK,CAAC,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;AAC5C,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAC,aAAa,CAAC,CAAC;AAC3D,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAC,YAAY,CAAC,CAAC;AAEzD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;IACzB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;SAC1B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QACzB,GAAG,EAAE,UAAU;KAClB,CAAC,CAAC;SACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;AAC3C,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;IACzB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC;SAC1B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QACzB,GAAG,EAAE,SAAS;KACjB,CAAC,CAAC;SACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;AAC3C,CAAC,CAAC,CAAC"}
|
|
42
ts/index.ts
42
ts/index.ts
@ -1,29 +1,13 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
var plugins = {
|
/// <reference path="./npmts.plugins.ts" />
|
||||||
beautylog: require("beautylog"),
|
/// <reference path="./npmts.cli.ts" />
|
||||||
gulp: require("gulp"),
|
/// <reference path="./npmts.paths.ts" />
|
||||||
gulpTypeScript: require("gulp-typescript"),
|
/// <reference path="./npmts.options.ts" />
|
||||||
path: require("path"),
|
/// <reference path="./npmts.custom.ts" />
|
||||||
smartcli: require("smartcli")
|
/// <reference path="./npmts.default.ts" />
|
||||||
};
|
/// <reference path="./npmts.tests.ts" />
|
||||||
|
/// <reference path="./npmts.promisechain.ts" />
|
||||||
var paths:any = {};
|
console.log("**** starting NPMTS ****")
|
||||||
paths.cwd = plugins.smartcli.get.cwd().path;
|
var plugins = NpmtsPlugins.init();
|
||||||
paths.indexTS = plugins.path.join(paths.cwd,"ts/index.ts");
|
var paths = NpmtsPaths.init();
|
||||||
paths.testTS = plugins.path.join(paths.cwd,"ts/test.ts");
|
var promisechain = NpmtsPromisechain.init();
|
||||||
|
|
||||||
plugins.gulp.task("indexTS", function(){
|
|
||||||
plugins.gulp.src(paths.indexTS)
|
|
||||||
.pipe(plugins.gulpTypeScript({
|
|
||||||
out: "index.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd))
|
|
||||||
});
|
|
||||||
|
|
||||||
plugins.gulp.task("indexTS", function(){
|
|
||||||
plugins.gulp.src(paths.indexTS)
|
|
||||||
.pipe(plugins.gulpTypeScript({
|
|
||||||
out: "test.js"
|
|
||||||
}))
|
|
||||||
.pipe(plugins.gulp.dest(paths.cwd))
|
|
||||||
});
|
|
||||||
|
1
ts/npmts.cli.ts
Normal file
1
ts/npmts.cli.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
96
ts/npmts.custom.ts
Normal file
96
ts/npmts.custom.ts
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
module NpmtsCustom {
|
||||||
|
export var run = function(){
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
var config = NpmtsOptions.config;
|
||||||
|
if(config.mode === "custom"){
|
||||||
|
plugins.beautylog.log("now running custom tasks");
|
||||||
|
var moduleStream = plugins.mergeStream({end: false});
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- first install typings ---------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
var typingsDone = plugins.q.defer();
|
||||||
|
var typingsCounter:number = 0;
|
||||||
|
var typingsCounterAdvance = function(){
|
||||||
|
typingsCounter++;
|
||||||
|
if(typeof config.typings[typingsCounter] != "undefined"){
|
||||||
|
installTypings();
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.success("custom typings installed successfully");
|
||||||
|
typingsDone.resolve();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var installTypings = function() {
|
||||||
|
plugins.beautylog.log("now installing " + "typings.json".yellow + " from " + config.typings[typingsCounter].blue);
|
||||||
|
plugins.typings.install({production: false, cwd: plugins.path.join(paths.cwd,config.typings[typingsCounter])})
|
||||||
|
.then(function(){
|
||||||
|
typingsCounterAdvance();
|
||||||
|
},function(){
|
||||||
|
plugins.beautylog.error("something went wrong: Check if path is correct: " + config.typings[typingsCounter].blue);
|
||||||
|
typingsCounterAdvance();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
installTypings();
|
||||||
|
/* -------------------------------------------------
|
||||||
|
* ----------- second compile TS -------------------
|
||||||
|
* ----------------------------------------------- */
|
||||||
|
typingsDone.promise.then(function(){
|
||||||
|
for (var key in config.ts) {
|
||||||
|
plugins.beautylog.log("now compiling" + key.blue);
|
||||||
|
var outputPathIsDir:boolean;
|
||||||
|
try {
|
||||||
|
if(plugins.fs.statSync(plugins.path.join(paths.cwd,config.ts[key])).isDirectory()){
|
||||||
|
outputPathIsDir = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(err) {
|
||||||
|
outputPathIsDir = false;
|
||||||
|
}
|
||||||
|
//do some evaluation of the environment
|
||||||
|
var outputNameSpecified:boolean = (
|
||||||
|
!outputPathIsDir
|
||||||
|
&& (plugins.path.extname(config.ts[key]) == ".js")
|
||||||
|
);
|
||||||
|
console.log("outputNameSpecified");
|
||||||
|
var outputName = (function(){
|
||||||
|
if(outputNameSpecified){
|
||||||
|
return plugins.path.basename(config.ts[key])
|
||||||
|
} else {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
var outputDir = (function(){
|
||||||
|
if(outputNameSpecified){
|
||||||
|
return plugins.path.dirname(
|
||||||
|
plugins.path.join(paths.cwd,config.ts[key])
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return plugins.path.join(paths.cwd,config.ts[key])
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
var tsStream = plugins.gulp.src(plugins.path.join(paths.cwd,key))
|
||||||
|
.pipe(plugins.g.typescript({
|
||||||
|
out: outputName,
|
||||||
|
declaration: true
|
||||||
|
}));
|
||||||
|
var stream = plugins.mergeStream([
|
||||||
|
tsStream.dts.pipe(plugins.gulp.dest(outputDir)),
|
||||||
|
tsStream.js
|
||||||
|
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
|
||||||
|
.pipe(plugins.gulp.dest(outputDir))
|
||||||
|
]);
|
||||||
|
moduleStream.add(stream);
|
||||||
|
}
|
||||||
|
moduleStream.on("queueDrain",function(){
|
||||||
|
plugins.beautylog.success("custom TypeScript installed successfully");
|
||||||
|
moduleStream.on("finish",function(){
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
moduleStream.end();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return done.promise;
|
||||||
|
}
|
||||||
|
}
|
58
ts/npmts.default.ts
Normal file
58
ts/npmts.default.ts
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
|
||||||
|
module NpmtsDefault {
|
||||||
|
export var run = function() {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
plugins.gulp.task("defaultTypings",function(cb){
|
||||||
|
plugins.beautylog.log("now installing default typings");
|
||||||
|
plugins.typings.install({production: false, cwd: paths.tsDir})
|
||||||
|
.then(function(){
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
plugins.gulp.task("defaultIndexTS", function(){
|
||||||
|
plugins.beautylog.log("now compiling" + " ts/index.ts".blue);
|
||||||
|
var tsResult = plugins.gulp.src(paths.indexTS)
|
||||||
|
.pipe(plugins.g.typescript({
|
||||||
|
out:"./index.js",
|
||||||
|
declaration:true
|
||||||
|
}));
|
||||||
|
|
||||||
|
return plugins.mergeStream([
|
||||||
|
tsResult.dts.pipe(plugins.gulp.dest(paths.cwd)),
|
||||||
|
tsResult.js
|
||||||
|
.pipe(plugins.g.insert.prepend('#!/usr/bin/env node\n\n'))
|
||||||
|
.pipe(plugins.gulp.dest(paths.cwd))
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
plugins.gulp.task("defaultTestTS", function(){
|
||||||
|
plugins.beautylog.log("now compiling" + " ts/test.ts".blue);
|
||||||
|
var stream = plugins.gulp.src(paths.testTS)
|
||||||
|
.pipe(plugins.g.typescript({
|
||||||
|
out: "test.js"
|
||||||
|
}))
|
||||||
|
.pipe(plugins.gulp.dest(paths.testDir));
|
||||||
|
return stream;
|
||||||
|
});
|
||||||
|
|
||||||
|
plugins.gulp.task("defaultCleanup",function(cb){
|
||||||
|
plugins.beautylog.success("default TypeScript for this module compiled successfully.");
|
||||||
|
done.resolve();
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
|
||||||
|
plugins.gulp.task("default",function(cb){
|
||||||
|
if(NpmtsOptions.config.mode == "default"){
|
||||||
|
plugins.g.sequence("defaultTypings","defaultIndexTS","defaultTestTS","defaultCleanup",cb);
|
||||||
|
} else {
|
||||||
|
cb();
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
||||||
|
return done.promise;
|
||||||
|
}
|
||||||
|
}
|
29
ts/npmts.options.ts
Normal file
29
ts/npmts.options.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
module NpmtsOptions {
|
||||||
|
export var config:any = {};
|
||||||
|
export var run = function(){
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
var configPath = plugins.path.join(paths.cwd,"npmts.json");
|
||||||
|
if(plugins.smartfile.checks.fileExistsSync(configPath)){
|
||||||
|
plugins.beautylog.info("npmts.json".blue + " config file found!");
|
||||||
|
config = plugins.smartfile.readFileToObject(configPath);
|
||||||
|
switch (config.mode){
|
||||||
|
case "default":
|
||||||
|
plugins.beautylog.log("mode is " + config.mode.yellow);
|
||||||
|
done.resolve();
|
||||||
|
break;
|
||||||
|
case "custom":
|
||||||
|
plugins.beautylog.log("mode is " + config.mode.yellow);
|
||||||
|
done.resolve();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
plugins.beautylog.error("mode " + config.mode.yellow + " not recognised!".red);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.log("no config file found: so mode is " + "default".yellow);
|
||||||
|
config.mode = "default";
|
||||||
|
done.resolve();
|
||||||
|
};
|
||||||
|
return done.promise;
|
||||||
|
}
|
||||||
|
}
|
12
ts/npmts.paths.ts
Normal file
12
ts/npmts.paths.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
module NpmtsPaths {
|
||||||
|
export var init = function() {
|
||||||
|
var paths:any = {};
|
||||||
|
paths.cwd = plugins.smartcli.get.cwd().path;
|
||||||
|
paths.tsDir = plugins.path.join(paths.cwd,"ts/");
|
||||||
|
paths.indexTS = plugins.path.join(paths.cwd,"ts/index.ts");
|
||||||
|
paths.testTS = plugins.path.join(paths.cwd,"ts/test.ts");
|
||||||
|
paths.testDir = plugins.path.join(paths.cwd,"test/");
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
|
}
|
25
ts/npmts.plugins.ts
Normal file
25
ts/npmts.plugins.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
module NpmtsPlugins {
|
||||||
|
export var init = function() {
|
||||||
|
var plugins = {
|
||||||
|
beautylog: require("beautylog"),
|
||||||
|
fs: require("fs-extra"),
|
||||||
|
gulp: require("gulp"),
|
||||||
|
g: {
|
||||||
|
insert: require("gulp-insert"),
|
||||||
|
sequence: require("gulp-sequence"),
|
||||||
|
typescript: require("gulp-typescript")
|
||||||
|
|
||||||
|
},
|
||||||
|
mathjs: require("mathjs"),
|
||||||
|
mergeStream: require("merge2"),
|
||||||
|
mocha: require("mocha"),
|
||||||
|
path: require("path"),
|
||||||
|
q:require("q"),
|
||||||
|
smartcli: require("smartcli"),
|
||||||
|
smartfile: require("smartfile"),
|
||||||
|
typings: require("typings")
|
||||||
|
};
|
||||||
|
return plugins;
|
||||||
|
}
|
||||||
|
}
|
11
ts/npmts.promisechain.ts
Normal file
11
ts/npmts.promisechain.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
module NpmtsPromisechain {
|
||||||
|
export var init = function(){
|
||||||
|
var promisechain;
|
||||||
|
NpmtsOptions.run()
|
||||||
|
.then(NpmtsDefault.run)
|
||||||
|
.then(NpmtsCustom.run)
|
||||||
|
.then(NpmtsTests.run);
|
||||||
|
return promisechain;
|
||||||
|
}
|
||||||
|
}
|
19
ts/npmts.tests.ts
Normal file
19
ts/npmts.tests.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
module NpmtsTests {
|
||||||
|
export var run = function() {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
plugins.fs.ensureDirSync(paths.testDir); //make sure that mocha has a directory to look for tests
|
||||||
|
plugins.beautylog.info("Now running mocha tests");
|
||||||
|
|
||||||
|
var mocha = new plugins.mocha(); // Instantiate a Mocha instance.
|
||||||
|
mocha.addFile(
|
||||||
|
plugins.path.join(paths.testDir, "test.js")
|
||||||
|
);
|
||||||
|
mocha.run(function(failures){
|
||||||
|
process.on('exit', function () {
|
||||||
|
process.exit(failures);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
}
|
||||||
|
}
|
18
ts/tsd.json
18
ts/tsd.json
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "v4",
|
|
||||||
"repo": "borisyankov/DefinitelyTyped",
|
|
||||||
"ref": "master",
|
|
||||||
"path": "typings",
|
|
||||||
"bundle": "typings/tsd.d.ts",
|
|
||||||
"installed": {
|
|
||||||
"node/node.d.ts": {
|
|
||||||
"commit": "78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
|
||||||
},
|
|
||||||
"colors/colors.d.ts": {
|
|
||||||
"commit": "09e37435ffb2c56a6f908081194a74756f24f99d"
|
|
||||||
},
|
|
||||||
"vinyl/vinyl.d.ts": {
|
|
||||||
"commit": "78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
7
ts/typings.json
Normal file
7
ts/typings.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ambientDependencies": {
|
||||||
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777",
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts#09e37435ffb2c56a6f908081194a74756f24f99d",
|
||||||
|
"vinyl": "github:DefinitelyTyped/DefinitelyTyped/vinyl/vinyl.d.ts#78d36dd49b6b55b9fdfe61776a12bf05c8b07777"
|
||||||
|
}
|
||||||
|
}
|
3
ts/typings/browser.d.ts
vendored
Normal file
3
ts/typings/browser.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/// <reference path="browser/ambient/colors/colors.d.ts" />
|
||||||
|
/// <reference path="browser/ambient/node/node.d.ts" />
|
||||||
|
/// <reference path="browser/ambient/vinyl/vinyl.d.ts" />
|
@ -1,3 +1,5 @@
|
|||||||
|
// Compiled using typings@0.6.3
|
||||||
|
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/09e37435ffb2c56a6f908081194a74756f24f99d/colors/colors.d.ts
|
||||||
// Type definitions for Colors.js 0.6.0-1
|
// Type definitions for Colors.js 0.6.0-1
|
||||||
// Project: https://github.com/Marak/colors.js
|
// Project: https://github.com/Marak/colors.js
|
||||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||||
@ -120,4 +122,4 @@ interface String {
|
|||||||
america: string;
|
america: string;
|
||||||
trap: string;
|
trap: string;
|
||||||
random: string;
|
random: string;
|
||||||
}
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
// Compiled using typings@0.6.3
|
||||||
|
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/78d36dd49b6b55b9fdfe61776a12bf05c8b07777/node/node.d.ts
|
||||||
// Type definitions for Node.js v4.x
|
// Type definitions for Node.js v4.x
|
||||||
// Project: http://nodejs.org/
|
// Project: http://nodejs.org/
|
||||||
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>, DefinitelyTyped <https://github.com/borisyankov/DefinitelyTyped>
|
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>, DefinitelyTyped <https://github.com/borisyankov/DefinitelyTyped>
|
||||||
@ -2087,4 +2089,4 @@ declare module "constants" {
|
|||||||
export var W_OK: number;
|
export var W_OK: number;
|
||||||
export var X_OK: number;
|
export var X_OK: number;
|
||||||
export var UV_UDP_REUSEADDR: number;
|
export var UV_UDP_REUSEADDR: number;
|
||||||
}
|
}
|
@ -1,9 +1,10 @@
|
|||||||
|
// Compiled using typings@0.6.3
|
||||||
|
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/78d36dd49b6b55b9fdfe61776a12bf05c8b07777/vinyl/vinyl.d.ts
|
||||||
// Type definitions for vinyl 0.4.3
|
// Type definitions for vinyl 0.4.3
|
||||||
// Project: https://github.com/wearefractal/vinyl
|
// Project: https://github.com/wearefractal/vinyl
|
||||||
// Definitions by: vvakame <https://github.com/vvakame/>, jedmao <https://github.com/jedmao>
|
// Definitions by: vvakame <https://github.com/vvakame/>, jedmao <https://github.com/jedmao>
|
||||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||||
|
|
||||||
/// <reference path="../node/node.d.ts" />
|
|
||||||
|
|
||||||
declare module 'vinyl' {
|
declare module 'vinyl' {
|
||||||
|
|
||||||
@ -106,4 +107,4 @@ declare module 'vinyl' {
|
|||||||
|
|
||||||
export = File;
|
export = File;
|
||||||
|
|
||||||
}
|
}
|
3
ts/typings/main.d.ts
vendored
Normal file
3
ts/typings/main.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/// <reference path="main/ambient/colors/colors.d.ts" />
|
||||||
|
/// <reference path="main/ambient/node/node.d.ts" />
|
||||||
|
/// <reference path="main/ambient/vinyl/vinyl.d.ts" />
|
125
ts/typings/main/ambient/colors/colors.d.ts
vendored
Normal file
125
ts/typings/main/ambient/colors/colors.d.ts
vendored
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
// Compiled using typings@0.6.3
|
||||||
|
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/09e37435ffb2c56a6f908081194a74756f24f99d/colors/colors.d.ts
|
||||||
|
// Type definitions for Colors.js 0.6.0-1
|
||||||
|
// Project: https://github.com/Marak/colors.js
|
||||||
|
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||||
|
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||||
|
|
||||||
|
declare module "colors" {
|
||||||
|
interface Color {
|
||||||
|
(text: string): string;
|
||||||
|
|
||||||
|
black: Color;
|
||||||
|
red: Color;
|
||||||
|
green: Color;
|
||||||
|
yellow: Color;
|
||||||
|
blue: Color;
|
||||||
|
magenta: Color;
|
||||||
|
cyan: Color;
|
||||||
|
white: Color;
|
||||||
|
gray: Color;
|
||||||
|
grey: Color;
|
||||||
|
|
||||||
|
bgBlack: Color;
|
||||||
|
bgRed: Color;
|
||||||
|
bgGreen: Color;
|
||||||
|
bgYellow: Color;
|
||||||
|
bgBlue: Color;
|
||||||
|
bgMagenta: Color;
|
||||||
|
bgCyan: Color;
|
||||||
|
bgWhite: Color;
|
||||||
|
|
||||||
|
reset: Color;
|
||||||
|
bold: Color;
|
||||||
|
dim: Color;
|
||||||
|
italic: Color;
|
||||||
|
underline: Color;
|
||||||
|
inverse: Color;
|
||||||
|
hidden: Color;
|
||||||
|
strikethrough: Color;
|
||||||
|
|
||||||
|
rainbow: Color;
|
||||||
|
zebra: Color;
|
||||||
|
america: Color;
|
||||||
|
trap: Color;
|
||||||
|
random: Color;
|
||||||
|
}
|
||||||
|
|
||||||
|
module e {
|
||||||
|
export function setTheme(theme:any): void;
|
||||||
|
|
||||||
|
export var black: Color;
|
||||||
|
export var red: Color;
|
||||||
|
export var green: Color;
|
||||||
|
export var yellow: Color;
|
||||||
|
export var blue: Color;
|
||||||
|
export var magenta: Color;
|
||||||
|
export var cyan: Color;
|
||||||
|
export var white: Color;
|
||||||
|
export var gray: Color;
|
||||||
|
export var grey: Color;
|
||||||
|
|
||||||
|
export var bgBlack: Color;
|
||||||
|
export var bgRed: Color;
|
||||||
|
export var bgGreen: Color;
|
||||||
|
export var bgYellow: Color;
|
||||||
|
export var bgBlue: Color;
|
||||||
|
export var bgMagenta: Color;
|
||||||
|
export var bgCyan: Color;
|
||||||
|
export var bgWhite: Color;
|
||||||
|
|
||||||
|
export var reset: Color;
|
||||||
|
export var bold: Color;
|
||||||
|
export var dim: Color;
|
||||||
|
export var italic: Color;
|
||||||
|
export var underline: Color;
|
||||||
|
export var inverse: Color;
|
||||||
|
export var hidden: Color;
|
||||||
|
export var strikethrough: Color;
|
||||||
|
|
||||||
|
export var rainbow: Color;
|
||||||
|
export var zebra: Color;
|
||||||
|
export var america: Color;
|
||||||
|
export var trap: Color;
|
||||||
|
export var random: Color;
|
||||||
|
}
|
||||||
|
|
||||||
|
export = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface String {
|
||||||
|
black: string;
|
||||||
|
red: string;
|
||||||
|
green: string;
|
||||||
|
yellow: string;
|
||||||
|
blue: string;
|
||||||
|
magenta: string;
|
||||||
|
cyan: string;
|
||||||
|
white: string;
|
||||||
|
gray: string;
|
||||||
|
grey: string;
|
||||||
|
|
||||||
|
bgBlack: string;
|
||||||
|
bgRed: string;
|
||||||
|
bgGreen: string;
|
||||||
|
bgYellow: string;
|
||||||
|
bgBlue: string;
|
||||||
|
bgMagenta: string;
|
||||||
|
bgCyan: string;
|
||||||
|
bgWhite: string;
|
||||||
|
|
||||||
|
reset: string;
|
||||||
|
bold: string;
|
||||||
|
dim: string;
|
||||||
|
italic: string;
|
||||||
|
underline: string;
|
||||||
|
inverse: string;
|
||||||
|
hidden: string;
|
||||||
|
strikethrough: string;
|
||||||
|
|
||||||
|
rainbow: string;
|
||||||
|
zebra: string;
|
||||||
|
america: string;
|
||||||
|
trap: string;
|
||||||
|
random: string;
|
||||||
|
}
|
2092
ts/typings/main/ambient/node/node.d.ts
vendored
Normal file
2092
ts/typings/main/ambient/node/node.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
110
ts/typings/main/ambient/vinyl/vinyl.d.ts
vendored
Normal file
110
ts/typings/main/ambient/vinyl/vinyl.d.ts
vendored
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
// Compiled using typings@0.6.3
|
||||||
|
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/78d36dd49b6b55b9fdfe61776a12bf05c8b07777/vinyl/vinyl.d.ts
|
||||||
|
// Type definitions for vinyl 0.4.3
|
||||||
|
// Project: https://github.com/wearefractal/vinyl
|
||||||
|
// Definitions by: vvakame <https://github.com/vvakame/>, jedmao <https://github.com/jedmao>
|
||||||
|
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||||
|
|
||||||
|
|
||||||
|
declare module 'vinyl' {
|
||||||
|
|
||||||
|
import fs = require('fs');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A virtual file format.
|
||||||
|
*/
|
||||||
|
class File {
|
||||||
|
constructor(options?: {
|
||||||
|
/**
|
||||||
|
* Default: process.cwd()
|
||||||
|
*/
|
||||||
|
cwd?: string;
|
||||||
|
/**
|
||||||
|
* Used for relative pathing. Typically where a glob starts.
|
||||||
|
*/
|
||||||
|
base?: string;
|
||||||
|
/**
|
||||||
|
* Full path to the file.
|
||||||
|
*/
|
||||||
|
path?: string;
|
||||||
|
/**
|
||||||
|
* Path history. Has no effect if options.path is passed.
|
||||||
|
*/
|
||||||
|
history?: string[];
|
||||||
|
/**
|
||||||
|
* The result of an fs.stat call. See fs.Stats for more information.
|
||||||
|
*/
|
||||||
|
stat?: fs.Stats;
|
||||||
|
/**
|
||||||
|
* File contents.
|
||||||
|
* Type: Buffer, Stream, or null
|
||||||
|
*/
|
||||||
|
contents?: Buffer | NodeJS.ReadWriteStream;
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default: process.cwd()
|
||||||
|
*/
|
||||||
|
public cwd: string;
|
||||||
|
/**
|
||||||
|
* Used for relative pathing. Typically where a glob starts.
|
||||||
|
*/
|
||||||
|
public base: string;
|
||||||
|
/**
|
||||||
|
* Full path to the file.
|
||||||
|
*/
|
||||||
|
public path: string;
|
||||||
|
public stat: fs.Stats;
|
||||||
|
/**
|
||||||
|
* Type: Buffer|Stream|null (Default: null)
|
||||||
|
*/
|
||||||
|
public contents: Buffer | NodeJS.ReadableStream;
|
||||||
|
/**
|
||||||
|
* Returns path.relative for the file base and file path.
|
||||||
|
* Example:
|
||||||
|
* var file = new File({
|
||||||
|
* cwd: "/",
|
||||||
|
* base: "/test/",
|
||||||
|
* path: "/test/file.js"
|
||||||
|
* });
|
||||||
|
* console.log(file.relative); // file.js
|
||||||
|
*/
|
||||||
|
public relative: string;
|
||||||
|
|
||||||
|
public isBuffer(): boolean;
|
||||||
|
|
||||||
|
public isStream(): boolean;
|
||||||
|
|
||||||
|
public isNull(): boolean;
|
||||||
|
|
||||||
|
public isDirectory(): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new File object with all attributes cloned. Custom attributes are deep-cloned.
|
||||||
|
*/
|
||||||
|
public clone(opts?: { contents?: boolean }): File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If file.contents is a Buffer, it will write it to the stream.
|
||||||
|
* If file.contents is a Stream, it will pipe it to the stream.
|
||||||
|
* If file.contents is null, it will do nothing.
|
||||||
|
*/
|
||||||
|
public pipe<T extends NodeJS.ReadWriteStream>(
|
||||||
|
stream: T,
|
||||||
|
opts?: {
|
||||||
|
/**
|
||||||
|
* If false, the destination stream will not be ended (same as node core).
|
||||||
|
*/
|
||||||
|
end?: boolean;
|
||||||
|
}
|
||||||
|
): T;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a pretty String interpretation of the File. Useful for console.log.
|
||||||
|
*/
|
||||||
|
public inspect(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export = File;
|
||||||
|
|
||||||
|
}
|
3
ts/typings/tsd.d.ts
vendored
3
ts/typings/tsd.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
/// <reference path="node/node.d.ts" />
|
|
||||||
/// <reference path="colors/colors.d.ts" />
|
|
||||||
/// <reference path="vinyl/vinyl.d.ts" />
|
|
Reference in New Issue
Block a user