Fixed up Stylecop hook-up and fixed styling errors

This commit is contained in:
Leo Lee (DEVDIV) 2015-02-03 11:36:13 -08:00
Родитель a1373a04e6
Коммит 45a68094ef
4 изменённых файлов: 31 добавлений и 41 удалений

Просмотреть файл

@ -3,5 +3,5 @@
"compiledGulp": "../build", "compiledGulp": "../build",
"bin": "../build/src", "bin": "../build/src",
"tools": "../build/tools", "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/node.d.ts" />
/// <reference path="typings/q.d.ts" /> /// <reference path="typings/q.d.ts" />
var fs = require("fs"); var fs = require("fs");
var gulp = require("gulp"); var gulp = require("gulp");
var del = require("del"); var del = require("del");
var path = require("path"); var path = require("path");
var exec = require("child_process").exec; var exec = require("child_process").exec;
import dtsUtil = require("../tools/tsdefinition-util"); import dtsUtil = require ("../tools/tsdefinition-util");
import stylecopUtil = require("../tools/stylecop-util"); import stylecopUtil = require ("../tools/stylecop-util");
import tsUtil = require("./taco-cli/compile/typescript-util"); import tsUtil = require ("./taco-cli/compile/typescript-util");
var buildConfig = require("../../src/build_config.json"); var buildConfig = require("../../src/build_config.json");
/* Default task for building /src folder into /bin */ /* Default task for building /src folder into /bin */
@ -28,17 +27,16 @@ gulp.task("build", ["compile"], function (callback: Function): void {
gulp.run("copy"); gulp.run("copy");
}); });
/* full clean build */ /* full clean build */
gulp.task("rebuild", ["clean"], function (callback: Function): void { gulp.task("rebuild", ["clean"], function (callback: Function): void {
gulp.run("build"); gulp.run("build");
}); });
/* Runs style cop on the sources. */ /* Runs style cop on the sources. */
gulp.task("run-stylecop", ["clean-build"], function (callback: Function): void { gulp.task("run-stylecop", function (callback: Function): void {
if (fs.existsSync("copFile")) { if (fs.existsSync(buildConfig.copPath)) {
var styleCop = new stylecopUtil.StyleCopUtil(); var styleCop = new stylecopUtil.StyleCopUtil();
styleCop.runCop(buildConfig.src, buildConfig.copFile, callback); styleCop.runCop(buildConfig.src, buildConfig.copPath, callback);
} else { } else {
callback(); callback();
} }

Просмотреть файл

@ -1,22 +1,21 @@
///<reference path="../../typings/taco-utils.d.ts"/> /// <reference path="../../typings/taco-utils.d.ts" />
///<reference path="../../typings/node.d.ts"/> /// <reference path="../../typings/node.d.ts" />
///<reference path="../../typings/nopt.d.ts"/> /// <reference path="../../typings/nopt.d.ts" />
import tacoUtility = require("taco-utils");
import nopt = require("nopt");
import path = require("path");
import tacoUtility = require ("taco-utils");
import nopt = require ("nopt");
import path = require ("path");
class Taco { class Taco {
constructor() { constructor() {
var resourcePath: string = path.resolve("../resources"); var resourcePath: string = path.resolve("../resources");
tacoUtility.ResourcesManager.init("en", resourcePath); tacoUtility.ResourcesManager.init("en", resourcePath);
} }
run(): void {
public run(): void {
console.log(tacoUtility.ResourcesManager.getString("usage")); console.log(tacoUtility.ResourcesManager.getString("usage"));
} }
} }
var taco = new Taco(); var taco = new Taco();
taco.run(); taco.run();

Просмотреть файл

@ -1,32 +1,31 @@
///<reference path="../typings/node.d.ts"/> /// <reference path="../typings/node.d.ts" />
"use strict"; "use strict";
import fs = require("fs"); import fs = require ("fs");
import path = require("path"); import path = require ("path");
module TacoUtility { 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 { export class ResourcesManager {
static resources: any = null; private static Resources: any = null;
static defaultLanguage: string = "en"; private static DefaultLanguage: string = "en";
static init(language: string, resourcesDir?: string) { public static init(language: string, resourcesDir?: string): void {
if (!resourcesDir) { if (!resourcesDir) {
resourcesDir = path.join(__dirname, "..", "resources"); resourcesDir = path.join(__dirname, "..", "resources");
} }
var lang = this.bestLanguageMatchOrDefault(language, resourcesDir); 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***/ /* ...optionalArgs is only there for typings, function rest params */
static getString(id: string, ...optionalArgs: any[]): string { public static getString(id: string, ...optionalArgs: any[]): string {
if (!this.resources) { if (!this.Resources) {
throw new Error("Resources have not been loaded"); throw new Error("Resources have not been loaded");
} }
var s = this.resources[id]; var s = this.Resources[id];
if (!s) { if (!s) {
return s; return s;
} }
@ -44,7 +43,7 @@ module TacoUtility {
return s; return s;
} }
static bestLanguageMatchOrDefault(language: string, resourcesDir: string): string { public static bestLanguageMatchOrDefault(language: string, resourcesDir: string): string {
if (!language) { if (!language) {
return this.defaultLanguage; return this.defaultLanguage;
} }
@ -72,12 +71,12 @@ module TacoUtility {
return this.defaultLanguage; 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"); var resourcesPath = path.join(resourcesDir, language, "resources.json");
return require(resourcesPath); return require(resourcesPath);
} }
static getOptionalArgsArrayFromFunctionCall(functionArguments: IArguments, startFrom: number): any[] { public static getOptionalArgsArrayFromFunctionCall(functionArguments: IArguments, startFrom: number): any[] {
if (functionArguments.length <= startFrom) { if (functionArguments.length <= startFrom) {
return null; return null;
} }
@ -91,10 +90,4 @@ module TacoUtility {
} }
} }
export = TacoUtility; export = TacoUtility;