зеркало из https://github.com/microsoft/TACO.git
Fixed up Stylecop hook-up and fixed styling errors
This commit is contained in:
Родитель
a1373a04e6
Коммит
45a68094ef
|
@ -3,5 +3,5 @@
|
|||
"compiledGulp": "../build",
|
||||
"bin": "../build/src",
|
||||
"tools": "../build/tools",
|
||||
"copPath": "../tools/internal/TSStyleCop.js"
|
||||
"copPath": "../tools/internal/TSStyleCop/TSStyleCop.js"
|
||||
}
|
|
@ -1,15 +1,14 @@
|
|||
/// <reference path="typings/node.d.ts" />
|
||||
/// <reference path="typings/q.d.ts" />
|
||||
|
||||
|
||||
var fs = require("fs");
|
||||
var gulp = require("gulp");
|
||||
var del = require("del");
|
||||
var path = require("path");
|
||||
var exec = require("child_process").exec;
|
||||
import dtsUtil = require("../tools/tsdefinition-util");
|
||||
import stylecopUtil = require("../tools/stylecop-util");
|
||||
import tsUtil = require("./taco-cli/compile/typescript-util");
|
||||
import dtsUtil = require ("../tools/tsdefinition-util");
|
||||
import stylecopUtil = require ("../tools/stylecop-util");
|
||||
import tsUtil = require ("./taco-cli/compile/typescript-util");
|
||||
var buildConfig = require("../../src/build_config.json");
|
||||
|
||||
/* Default task for building /src folder into /bin */
|
||||
|
@ -28,17 +27,16 @@ gulp.task("build", ["compile"], function (callback: Function): void {
|
|||
gulp.run("copy");
|
||||
});
|
||||
|
||||
|
||||
/* full clean build */
|
||||
gulp.task("rebuild", ["clean"], function (callback: Function): void {
|
||||
gulp.run("build");
|
||||
});
|
||||
|
||||
/* Runs style cop on the sources. */
|
||||
gulp.task("run-stylecop", ["clean-build"], function (callback: Function): void {
|
||||
if (fs.existsSync("copFile")) {
|
||||
gulp.task("run-stylecop", function (callback: Function): void {
|
||||
if (fs.existsSync(buildConfig.copPath)) {
|
||||
var styleCop = new stylecopUtil.StyleCopUtil();
|
||||
styleCop.runCop(buildConfig.src, buildConfig.copFile, callback);
|
||||
styleCop.runCop(buildConfig.src, buildConfig.copPath, callback);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
///<reference path="../../typings/taco-utils.d.ts"/>
|
||||
///<reference path="../../typings/node.d.ts"/>
|
||||
///<reference path="../../typings/nopt.d.ts"/>
|
||||
|
||||
import tacoUtility = require("taco-utils");
|
||||
import nopt = require("nopt");
|
||||
import path = require("path");
|
||||
/// <reference path="../../typings/taco-utils.d.ts" />
|
||||
/// <reference path="../../typings/node.d.ts" />
|
||||
/// <reference path="../../typings/nopt.d.ts" />
|
||||
|
||||
import tacoUtility = require ("taco-utils");
|
||||
import nopt = require ("nopt");
|
||||
import path = require ("path");
|
||||
|
||||
class Taco {
|
||||
constructor() {
|
||||
var resourcePath: string = path.resolve("../resources");
|
||||
tacoUtility.ResourcesManager.init("en", resourcePath);
|
||||
}
|
||||
run(): void {
|
||||
|
||||
public run(): void {
|
||||
console.log(tacoUtility.ResourcesManager.getString("usage"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var taco = new Taco();
|
||||
taco.run();
|
|
@ -1,32 +1,31 @@
|
|||
///<reference path="../typings/node.d.ts"/>
|
||||
/// <reference path="../typings/node.d.ts" />
|
||||
"use strict";
|
||||
|
||||
import fs = require("fs");
|
||||
import path = require("path");
|
||||
import fs = require ("fs");
|
||||
import path = require ("path");
|
||||
|
||||
module TacoUtility {
|
||||
|
||||
//put more classes here, known limitation that classes in external modules CANNOT span multiple files
|
||||
// put more classes here, known limitation that classes in external modules CANNOT span multiple files
|
||||
export class ResourcesManager {
|
||||
static resources: any = null;
|
||||
static defaultLanguage: string = "en";
|
||||
private static Resources: any = null;
|
||||
private static DefaultLanguage: string = "en";
|
||||
|
||||
static init(language: string, resourcesDir?: string) {
|
||||
public static init(language: string, resourcesDir?: string): void {
|
||||
if (!resourcesDir) {
|
||||
resourcesDir = path.join(__dirname, "..", "resources");
|
||||
}
|
||||
|
||||
var lang = this.bestLanguageMatchOrDefault(language, resourcesDir);
|
||||
this.resources = this.loadLanguage(lang, resourcesDir);
|
||||
this.Resources = this.loadLanguage(lang, resourcesDir);
|
||||
}
|
||||
|
||||
/**** ...optionalArgs is only there for typings, function rest params***/
|
||||
static getString(id: string, ...optionalArgs: any[]): string {
|
||||
if (!this.resources) {
|
||||
/* ...optionalArgs is only there for typings, function rest params */
|
||||
public static getString(id: string, ...optionalArgs: any[]): string {
|
||||
if (!this.Resources) {
|
||||
throw new Error("Resources have not been loaded");
|
||||
}
|
||||
|
||||
var s = this.resources[id];
|
||||
var s = this.Resources[id];
|
||||
if (!s) {
|
||||
return s;
|
||||
}
|
||||
|
@ -44,7 +43,7 @@ module TacoUtility {
|
|||
return s;
|
||||
}
|
||||
|
||||
static bestLanguageMatchOrDefault(language: string, resourcesDir: string): string {
|
||||
public static bestLanguageMatchOrDefault(language: string, resourcesDir: string): string {
|
||||
if (!language) {
|
||||
return this.defaultLanguage;
|
||||
}
|
||||
|
@ -72,12 +71,12 @@ module TacoUtility {
|
|||
return this.defaultLanguage;
|
||||
}
|
||||
|
||||
static loadLanguage(language: string, resourcesDir: string): any {
|
||||
public static loadLanguage(language: string, resourcesDir: string): any {
|
||||
var resourcesPath = path.join(resourcesDir, language, "resources.json");
|
||||
return require(resourcesPath);
|
||||
}
|
||||
|
||||
static getOptionalArgsArrayFromFunctionCall(functionArguments: IArguments, startFrom: number): any[] {
|
||||
public static getOptionalArgsArrayFromFunctionCall(functionArguments: IArguments, startFrom: number): any[] {
|
||||
if (functionArguments.length <= startFrom) {
|
||||
return null;
|
||||
}
|
||||
|
@ -91,10 +90,4 @@ module TacoUtility {
|
|||
}
|
||||
}
|
||||
|
||||
export = TacoUtility;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export = TacoUtility;
|
Загрузка…
Ссылка в новой задаче