Files
code_tool_fly/VSCode-win32-x64-1.74.0/resources/app/extensions/grunt/dist/main.js
T

2 lines
5.3 KiB
JavaScript
Raw Normal View History

2025-05-09 16:55:09 +08:00
(()=>{"use strict";var t={129:t=>{t.exports=require("child_process")},747:t=>{t.exports=require("fs")},622:t=>{t.exports=require("path")},549:t=>{t.exports=require("vscode")}},e={};function s(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i](o,o.exports,s),o.exports}var i={};(()=>{var t=i;Object.defineProperty(t,"__esModule",{value:!0}),t.deactivate=t.activate=void 0;const e=s(622),r=s(747),o=s(129),n=s(549);function a(t){return new Promise(((e,s)=>{r.exists(t,(t=>{e(t)}))}))}const c=["build","compile","watch"];function u(t){for(const e of c)if(-1!==t.indexOf(e))return!0;return!1}const d=["test"];function h(t){for(const e of d)if(-1!==t.indexOf(e))return!0;return!1}let l,f;function p(){return l||(l=n.window.createOutputChannel("Grunt Auto Detection")),l}function w(){n.window.showWarningMessage(n.l10n.t("Problem finding grunt tasks. See the output for more information."),n.l10n.t("Go to output")).then((()=>{p().show(!0)}))}async function g(t){let s;const i=process.platform;return s="win32"===i&&await a(e.join(t,"node_modules",".bin","grunt.cmd"))?e.join(".","node_modules",".bin","grunt.cmd"):"linux"!==i&&"darwin"!==i||!await a(e.join(t,"node_modules",".bin","grunt"))?"grunt":e.join(".","node_modules",".bin","grunt"),s}class k{constructor(t,e){this.c=t,this.d=e}get workspaceFolder(){return this.c}isEnabled(){return"on"===n.workspace.getConfiguration("grunt",this.c.uri).get("autoDetect")}start(){const t=e.join(this.c.uri.fsPath,"{node_modules,[Gg]runtfile.js}");this.a=n.workspace.createFileSystemWatcher(t),this.a.onDidChange((()=>this.b=void 0)),this.a.onDidCreate((()=>this.b=void 0)),this.a.onDidDelete((()=>this.b=void 0))}async getTasks(){return this.isEnabled()?(this.b||(this.b=this.e()),this.b):[]}async getTask(t){const e=t.definition,s=e.task;if(s){const t={cwd:this.workspaceFolder.uri.fsPath},i="grunt";return-1===s.indexOf(" ")?new n.Task(e,this.workspaceFolder,s,i,new n.ShellExecution(`${await this.d}`,[s,...e.args],t)):new n.Task(e,this.workspaceFolder,s,i,new n.ShellExecution(`${await this.d}`,[`"${s}"`,...e.args],t))}}async e(){const t="file"===this.c.uri.scheme?this.c.uri.fsPath:void 0,s=[];if(!t)return s;if(!await a(e.join(t,"gruntfile.js"))&&!await a(e.join(t,"Gruntfile.js")))return s;const i=`${await this.d} --help --no-color`;try{const{stdout:e,stderr:s}=await(r=i,c={cwd:t},new Promise(((t,e)=>{o.exec(r,c,((s,i,r)=>{s&&e({error:s,stdout:i,stderr:r}),t({stdout:i,stderr:r})}))})));s&&(p().appendLine(s),w());const a=[];if(e){const t=e.split(/\r{0,1}\n/);let s=!1,i=!1;for(const e of t)if(0!==e.length)if(s||i){if(s&&!i)if(0===e.indexOf("Tasks run in the order specified"))i=!0;else{const t=/^\s*(\S.*\S) \S/g.exec(e);if(t&&2===t.length){const e=t[1],s={type:"grunt",task:e},i="grunt",r={cwd:this.workspaceFolder.uri.fsPath},o=-1===e.indexOf(" ")?new n.Task(s,this.workspaceFolder,e,i,new n.ShellExecution(`${await this.d} ${e}`,r)):new n.Task(s,this.workspaceFolder,e,i,new n.ShellExecution(`${await this.d} "${e}"`,r));a.push(o);const c=e.toLowerCase();u(c)?o.group=n.TaskGroup.Build:h(c)&&(o.group=n.TaskGroup.Test)}}}else 0===e.indexOf("Available tasks")&&(s=!0)}return a}catch(t){const e=p();return t.stderr&&e.appendLine(t.stderr),t.stdout&&e.appendLine(t.stdout),e.appendLine(n.l10n.t("Auto detecting Grunt for folder {0} failed with error: {1}', this.workspaceFolder.name, err.error ? err.error.toString() : 'unknown")),w(),s}var r,c}dispose(){this.b=void 0,this.a&&this.a.dispose()}}class b{constructor(){this.b=new Map}start(){const t=n.workspace.workspaceFolders;t&&this.c(t,[]),n.workspace.onDidChangeWorkspaceFolders((t=>this.c(t.added,t.removed))),n.workspace.onDidChangeConfiguration(this.d,this)}dispose(){this.a&&(this.a.dispose(),this.a=void 0),this.b.clear()}c(t,e){for(const t of e){const e=this.b.get(t.uri.toString());e&&(e.dispose(),this.b.delete(t.uri.toString()))}for(const e of t){const t=new k(e,g(e.uri.fsPath));this.b.set(e.uri.toString(),t),t.isEnabled()&&t.start()}this.e()}d(){for(const t of this.b.values())t.dispose(),this.b.delete(t.workspaceFolder.uri.toString());const t=n.w
//# sourceMappingURL=https://ticino.blob.core.windows.net/sourcemaps/5235c6bb189b60b01b1f49062f4ffa42384f8c91/extensions/grunt/dist/main.js.map