-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathV8ScriptEngine.InitScript.tt
More file actions
34 lines (29 loc) · 1.27 KB
/
V8ScriptEngine.InitScript.tt
File metadata and controls
34 lines (29 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ output extension=".cs" #>
<#@ assembly name="EnvDTE" #>
<#@ assembly name="System.Net.Http" #>
<#@ import namespace="EnvDTE" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Net.Http" #>
<#
var dte = (DTE)((IServiceProvider)Host).GetService(typeof(DTE));
var solutionPath = Path.GetDirectoryName(dte.Solution.FullName);
var scriptPath = Path.Combine(solutionPath, "ClearScript", "V8", "V8ScriptEngine.InitScript.js");
var script = File.ReadAllText(scriptPath);
var contentData = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("input", script) };
using var client = new HttpClient();
using var content = new FormUrlEncodedContent(contentData);
using var response = client.PostAsync("https://www.toptal.com/developers/javascript-minifier/api/raw", content).Result;
response.EnsureSuccessStatusCode();
script = response.Content.ReadAsStringAsync().Result.Replace('\"', '\'');
#>
namespace Microsoft.ClearScript.V8
{
public sealed partial class V8ScriptEngine
{
private const string initScript = "<#= script #>";
}
}