Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
switch to gulp and babel for better es6 support. fix readline problem
  • Loading branch information
serkanyersen committed Dec 23, 2015
1 parent 83b7b52 commit 46c0ee1
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 106 deletions.
53 changes: 39 additions & 14 deletions .vscode/tasks.json
@@ -1,19 +1,44 @@
{
"version": "0.1.0",
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process

// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
"command": "tsc",
// {
// "version": "0.1.0",

// The command is a shell script
"isShellCommand": true,
// // The command is tsc. Assumes that tsc has been installed using npm install -g typescript
// "command": "tsc",

// // The command is a shell script
// "isShellCommand": true,

// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// // Show the output window only if unrecognized errors occur.
// "showOutput": "silent",

// Tell the tsc compiler to use the tsconfig.json from the open folder.
"args": ["-p", "."],
// // Tell the tsc compiler to use the tsconfig.json from the open folder.
// "args": ["-p", "."],

// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}
// // use the standard tsc problem matcher to find compile problems
// // in the output.
// "problemMatcher": "$tsc"
// }

{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"tasks": [
{
"taskName": "default",
// Make this the default build command.
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Use the standard less compilation problem matcher.
"problemMatcher": "$tsc"
}
]
}
2 changes: 1 addition & 1 deletion bin/syncjs
@@ -1,5 +1,5 @@
#!/usr/bin/env node
var path = require('path');
var Sync = require(path.resolve(__dirname, '../dist/src/index.js')).default;
var Sync = require(path.resolve(__dirname, '../dist/index.js')).default;

new Sync();
16 changes: 16 additions & 0 deletions gulpfile.js
@@ -0,0 +1,16 @@
var gulp = require('gulp');
var ts = require('gulp-typescript');
var babel = require('gulp-babel');

var tsProject = ts.createProject('./tsconfig.json', {
typescript: require('typescript')
});

gulp.task('default', function() {
return gulp.src(['src/**/*.ts', 'typings/**/*.ts'])
.pipe(ts(tsProject))
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('dist'));
});
11 changes: 7 additions & 4 deletions package.json
@@ -1,24 +1,27 @@
{
"name": "sync.js",
"version": "2.0.0",
"main": "dist/src/index.js",
"main": "dist/index.js",
"preferGlobal": true,
"scripts": {
"postinstall": "./node_modules/.bin/tsc"
"postinstall": "./node_modules/.bin/gulp"
},
"bin": {
"syncjs": "bin/syncjs"
},
"dependencies": {
"babel-preset-es2015": "^6.3.13",
"chalk": "^1.1.1",
"chokidar": "^1.2.0",
"es6-promise": "^3.0.2",
"gulp": "^3.9.0",
"gulp-babel": "^6.1.1",
"gulp-typescript": "^2.10.0",
"jsonplus": "^1.2.1",
"minimist": "^1.2.0",
"moment": "latest",
"readline-sync": "^1.2.21",
"scp2": "^0.2.2",
"typescript": "^1.7.*",
"typescript": "^1.8.0-dev.20151222",
"upath": "^0.1.6"
},
"description": "sync.js let's you keep your remote files in sync with your local copy. Whenever you make a change on your local project, sync.js uploads the changed files to remote server using `scp` command.",
Expand Down
20 changes: 12 additions & 8 deletions src/classes/CLI.ts
@@ -1,7 +1,6 @@
import * as chalk from "chalk";
import * as readline from "readline";
import * as minimist from "minimist";
var readlineSync = require("readline-sync");

export enum EXIT_CODE {
/**
Expand All @@ -25,11 +24,6 @@ export enum EXIT_CODE {
INVALID_ARGUMENT = 128
}

interface ReadLineOptions {
follow?: string;
hideEchoBack?: boolean
}

export default class CLI {

private rline: readline.ReadLine;
Expand All @@ -43,6 +37,17 @@ export default class CLI {
constructor() {
// Parse arguments
this.args = minimist(process.argv.slice(2));

try {
this.rline = readline.createInterface({
input: process.stdin,
output: process.stdout
});
} catch (e) {
this.write("You need to upgrade your nodejs\n");
this.write("http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/\n");
process.exit(EXIT_CODE.RUNTIME_FAILURE);
}
}

/**
Expand Down Expand Up @@ -85,8 +90,7 @@ export default class CLI {

read(question: string, password = false): Promise<string> {
return new Promise<string>((resolve) => {
let answer = readlineSync.question(question, { hideEchoBack: password });
resolve(answer);
this.rline.question(question, resolve);
});
}

Expand Down
1 change: 0 additions & 1 deletion src/index.ts
@@ -1,5 +1,4 @@
import Sync from "./classes/Sync";
import "es6-promise";

// Main Export
export default Sync;
2 changes: 1 addition & 1 deletion tsconfig.json
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"target": "es6",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"inlineSourceMap": true,
Expand Down
3 changes: 0 additions & 3 deletions tsd.json
Expand Up @@ -17,9 +17,6 @@
"node/node.d.ts": {
"commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff"
},
"es6-promise/es6-promise.d.ts": {
"commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff"
},
"moment/moment.d.ts": {
"commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff"
},
Expand Down
73 changes: 0 additions & 73 deletions typings/es6-promise/es6-promise.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion typings/tsd.d.ts
Expand Up @@ -2,7 +2,6 @@
/// <reference path="chalk/chalk.d.ts" />
/// <reference path="chokidar/chokidar.d.ts" />
/// <reference path="node/node.d.ts" />
/// <reference path="es6-promise/es6-promise.d.ts" />
/// <reference path="moment/moment-node.d.ts" />
/// <reference path="moment/moment.d.ts" />
/// <reference path="../node_modules/jsonplus/jsonplus.d.ts" />

0 comments on commit 46c0ee1

Please sign in to comment.