예제 #1
0
파일: Program.cs 프로젝트: jigjosh/Durandal
        static void Main(string[] args)
        {
            try {
            var hasNode = IO.ExistsOnPath("node.exe");
            if (!hasNode) {
              Console.WriteLine("Exiting - Node is not installed.");
              Console.WriteLine("Please visit http://nodejs.org/ to install nodejs.");
              return;
            }

            var options = new Options();
            if(CommandLineParser.Default.ParseArguments(args, options)) {
            #if DEBUG
            options.Verbose = true;
            #endif

              var configBuilder = new RJSConfigBuilder(options);
              var config = configBuilder.Build();

              if(options.Build || options.Generate) {
            IO.WriteConfiguration(config, options);
              }

              if(options.Build && !options.Generate) {
            var runner = new RJSRunner(config, options);
            runner.Run();
              }
            }
              } catch(Exception ex) {
            Console.WriteLine(ex.Message);
              }
        }
예제 #2
0
파일: IO.cs 프로젝트: steeleprice/Durandal
        public static void WriteConfiguration(RJSConfig info, Options options)
        {
            options.Log(info.Config);

            using (var file = File.Create(info.BuildFilePath))
            using (var writer = new StreamWriter(file)) {
                writer.Write(info.Config.ToString());
            }
        }
예제 #3
0
파일: IO.cs 프로젝트: steeleprice/Durandal
        static JObject ReadConfigFromResource(Options options)
        {
            options.Log("Using default base configuration.");

            using(var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Optimizer.optimizer.base.js"))
            using(var streamReader = new StreamReader(stream))
            using(var jsonReader = new JsonTextReader(streamReader)) {
                return JObject.Load(jsonReader);
            }
        }
예제 #4
0
파일: IO.cs 프로젝트: steeleprice/Durandal
        static JObject ReadConfigFromFile(string path, Options options)
        {
            options.Log("Reading configuration from " + path);

            using(var reader = File.OpenRead(path))
            using(var streamReader = new StreamReader(reader))
            using(var jsonReader = new JsonTextReader(streamReader)) {
                return JObject.Load(jsonReader);
            }
        }
예제 #5
0
파일: IO.cs 프로젝트: steeleprice/Durandal
        public static JObject GetBaseConfiguration(Options options)
        {
            if(!string.IsNullOrEmpty(options.ConfigurationSource)) {
                var fullPath = options.ConfigurationSource;
                if(!Path.IsPathRooted(fullPath)) {
                    fullPath = Path.Combine(Directory.GetCurrentDirectory(), fullPath);
                }

                return ReadConfigFromFile(fullPath, options);
            }

            var configPath = Path.Combine(Directory.GetCurrentDirectory(), "optimizer.base.js");
            if(File.Exists(configPath)) {
                return ReadConfigFromFile(configPath, options);
            }

            return ReadConfigFromResource(options);
        }
예제 #6
0
파일: IO.cs 프로젝트: nicolaihald/Durandal
        static JObject ReadConfigFromFile(string path, Options options)
        {
            options.Log("Reading configuration from " + path);

            using (var reader = File.OpenRead(path)) {
                using (var streamReader = new StreamReader(reader)) {
                    var json = streamReader.ReadToEnd();
                    //allows i.e. module.exports = { } instead of a plain json, so you'd have intellisense in VS2012
                    var index = 0;
                    if ((index = json.IndexOf("{")) >= 0)
                        json = json.Substring(index);
                    json = Regex.Replace(json, "\\%LANG\\%", options.Lang, RegexOptions.IgnoreCase);
                    //replace // comments with /* comments */
                    var jsonFixed = Regex.Replace(json, "(.*)//(.*)\r\n", "$1/*$2*/\r\n", RegexOptions.Multiline);
                    return JObject.Parse(jsonFixed);
                }
            }
        }
예제 #7
0
        static void Main(string[] args)
        {
            var options = new Options();
              if(CommandLineParser.Default.ParseArguments(args, options)) {
            #if DEBUG
            options.Verbose = true;
            #endif

            var configBuilder = new RJSConfigBuilder(options);
            var config = configBuilder.Build();

            if(options.Build || options.Generate) {
              IO.WriteConfiguration(config, options);
            }

            if(options.Build && !options.Generate) {
              var runner = new RJSRunner(config, options);
              runner.Run();
            }
              }
        }
예제 #8
0
 public RJSRunner(RJSConfig config, Options options)
 {
     this.config = config;
       this.options = options;
 }
예제 #9
0
 public RJSConfigBuilder(Options options)
 {
     this.options = options;
     extensionIncludes = new[] { ".js", options.ViewExtension };
 }
예제 #10
0
파일: IO.cs 프로젝트: nicolaihald/Durandal
        static JObject ReadConfigFromResource(Options options)
        {
            options.Log("Using default base configuration.");

            using (var stream = ReadFromResource("optimizer.base.js")) {
                using (var streamReader = new StreamReader(stream)) {
                    using (var jsonReader = new JsonTextReader(streamReader)) {
                        return JObject.Load(jsonReader);
                    }
                }
            }
        }