Exemplo n.º 1
0
        public override IProject Load(ISolution solution, string filename)
        {
            TypeScriptProject result = new TypeScriptProject();

            result.Location = filename;

            //TODO: Load TS language service from here

            result.Solution = solution;
            result.LoadFiles();

            return(result);
        }
Exemplo n.º 2
0
        public static TypeScriptProject Create(ISolution solution, string directory)
        {
            TypeScriptProject result = new TypeScriptProject();

            var projectName = new DirectoryInfo(directory).Name;

            //Create new project with default name and extension
            var projectFileLocation = Path.Combine(directory, projectName + $".{result.Extension}");

            result.Solution = solution;
            result.Location = projectFileLocation;

            //Create Main.TS file
            var indexFileLocation = Path.Combine(directory, "main.ts");

            if (!System.IO.File.Exists(indexFileLocation))
            {
                System.IO.File.WriteAllText(indexFileLocation, @"
class Program {
    static main() {
        console.log(""Hello, World!"");
    }
}

Program.main();
");
            }
            //Create TypeScript project file
            var tsProjectFileLocation = Path.Combine(directory, "tsconfig.json");

            if (!System.IO.File.Exists(tsProjectFileLocation))
            {
                System.IO.File.WriteAllText(tsProjectFileLocation, @"
{
    ""compilerOptions"": {
        ""target"": ""es5"",
        ""module"": ""commonjs"",
        ""sourceMap"": true
    }
}
");
            }
            result.Save();

            result.LoadFiles();

            return(result);
        }