예제 #1
0
 public Func <Stream> Transform(Func <Stream> openSourceStream, IAsset asset)
 {
     return(() =>
     {
         var source = openSourceStream().ReadToEnd();
         var output = ModulePathInserter.InsertModulePathIntoDefineCall(source, ModulePath);
         return output.AsStream();
     });
 }
예제 #2
0
 public static string InsertModulePathIntoDefineCall(string moduleScript, string modulePath)
 {
     var inserter = new ModulePathInserter();
     var parser = new JSParser(moduleScript);
     var sourceTree = parser.Parse(new CodeSettings { MinifyCode = false });
     sourceTree.Accept(inserter);
     if (inserter.insertionIndex > 0)
     {
         return moduleScript.Insert(inserter.insertionIndex, "\"" + modulePath + "\",");
     }
     else
     {
         return moduleScript;
     }
 }
예제 #3
0
            public static string InsertModulePathIntoDefineCall(string moduleScript, string modulePath)
            {
                var inserter   = new ModulePathInserter();
                var parser     = new JSParser(moduleScript);
                var sourceTree = parser.Parse(new CodeSettings {
                    MinifyCode = false
                });

                sourceTree.Accept(inserter);
                if (inserter.insertionIndex > 0)
                {
                    return(moduleScript.Insert(inserter.insertionIndex, "\"" + modulePath + "\","));
                }
                else
                {
                    return(moduleScript);
                }
            }