mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 21:13:28 -07:00
rjs -> webpack
This commit is contained in:
parent
344f3d66ef
commit
428a1439e5
399 changed files with 11591 additions and 16139 deletions
50
commonjsCleanup.linq
Normal file
50
commonjsCleanup.linq
Normal file
|
@ -0,0 +1,50 @@
|
|||
<Query Kind="Program" />
|
||||
|
||||
void Main()
|
||||
{
|
||||
var files = Directory.GetFiles("c:\\git\\sonarr\\src\\UI","*.js", SearchOption.AllDirectories);
|
||||
|
||||
var moduleRegex = new Regex(@"module.exports\s*=\s*\(function\s*\(\)\s*{\n\s*return\s*(\w|\W)*\)\.call\(this\);$");
|
||||
var functionHead = new Regex(@"\s*\(function\s*\(\)\s*{\n\s*return\s*");
|
||||
var functionTail = new Regex(@"\}\).call\(this\);$");
|
||||
var multiVar = new Regex(@"^(?<d>var\s*\w*\s*=\s*require\(.*\)),");
|
||||
var seperateDeclearatuin = new Regex(@"^((\w|\$|_)*\s=\srequire\(.*\))(,|;)", RegexOptions.Multiline);
|
||||
|
||||
foreach (var filePath in files)
|
||||
{
|
||||
var text = File.ReadAllText(filePath);
|
||||
|
||||
var newContent = text.Replace("// Generated by uRequire v0.7.0-beta.14 template: 'nodejs'","");
|
||||
|
||||
newContent = newContent.Replace("var __isAMD = !!(typeof define === 'function' && define.amd),","");
|
||||
newContent = newContent.Replace("__isNode = (typeof exports === 'object'),","");
|
||||
newContent = newContent.Replace("__isWeb = !__isNode;","");
|
||||
newContent = newContent.Replace("\"use strict\";","'use strict';");
|
||||
|
||||
newContent = newContent.Trim();
|
||||
|
||||
|
||||
|
||||
if(moduleRegex.IsMatch(newContent))
|
||||
{
|
||||
filePath.Dump();
|
||||
|
||||
newContent = functionHead.Replace(newContent," ");
|
||||
newContent = functionTail.Replace(newContent,"");
|
||||
}
|
||||
|
||||
if(multiVar.IsMatch(newContent))
|
||||
{
|
||||
newContent = multiVar.Replace(newContent,"$1;"); //first one
|
||||
|
||||
}
|
||||
|
||||
newContent = seperateDeclearatuin.Replace(newContent,"var $1;"); //ones after
|
||||
newContent.Replace("var $ = require('jquery'), var","var $ = require('jquery');");
|
||||
|
||||
File.WriteAllText(filePath,newContent.Trim());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Define other methods and classes here
|
Loading…
Add table
Add a link
Reference in a new issue