Files
2025-12-02 16:27:21 +00:00

2 lines
6.7 KiB
JavaScript

(()=>{"use strict";var e={184:function(e,t,r){var s,o=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,o)}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||(s=function(e){return s=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},s(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=s(e),n=0;n<r.length;n++)"default"!==r[n]&&o(t,e,r[n]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.activate=function(e){w=new T,w.start()},t.deactivate=function(){w.dispose()};const a=n(r(928)),c=n(r(896)),d=n(r(317)),u=n(r(398));function l(e){return new Promise((t,r)=>{c.exists(e,e=>{t(e)})})}const h=["build","compile","watch"];function p(e){for(const t of h)if(-1!==e.indexOf(t))return!0;return!1}const f=["test"];function g(e){for(const t of f)if(-1!==e.indexOf(t))return!0;return!1}let k,w;function v(){return k||(k=u.window.createOutputChannel("Grunt Auto Detection")),k}function m(){u.window.showWarningMessage(u.l10n.t("Problem finding grunt tasks. See the output for more information."),u.l10n.t("Go to output")).then(()=>{v().show(!0)})}async function _(e){let t;const r=process.platform;return t="win32"===r&&await l(a.join(e,"node_modules",".bin","grunt.cmd"))?a.join(".","node_modules",".bin","grunt.cmd"):"linux"!==r&&"darwin"!==r||!await l(a.join(e,"node_modules",".bin","grunt"))?"grunt":a.join(".","node_modules",".bin","grunt"),t}class P{_workspaceFolder;_gruntCommand;fileWatcher;promise;constructor(e,t){this._workspaceFolder=e,this._gruntCommand=t}get workspaceFolder(){return this._workspaceFolder}isEnabled(){return"on"===u.workspace.getConfiguration("grunt",this._workspaceFolder.uri).get("autoDetect")}start(){const e=a.join(this._workspaceFolder.uri.fsPath,"{node_modules,[Gg]runtfile.js}");this.fileWatcher=u.workspace.createFileSystemWatcher(e),this.fileWatcher.onDidChange(()=>this.promise=void 0),this.fileWatcher.onDidCreate(()=>this.promise=void 0),this.fileWatcher.onDidDelete(()=>this.promise=void 0)}async getTasks(){return this.isEnabled()?(this.promise||(this.promise=this.computeTasks()),this.promise):[]}async getTask(e){const t=e.definition,r=t.task;if(r){const e={cwd:this.workspaceFolder.uri.fsPath},s="grunt";return-1===r.indexOf(" ")?new u.Task(t,this.workspaceFolder,r,s,new u.ShellExecution(`${await this._gruntCommand}`,[r,...t.args],e)):new u.Task(t,this.workspaceFolder,r,s,new u.ShellExecution(`${await this._gruntCommand}`,[`"${r}"`,...t.args],e))}}async computeTasks(){const e="file"===this._workspaceFolder.uri.scheme?this._workspaceFolder.uri.fsPath:void 0,t=[];if(!e)return t;if(!await l(a.join(e,"gruntfile.js"))&&!await l(a.join(e,"Gruntfile.js")))return t;const r=`${await this._gruntCommand} --help --no-color`;try{const{stdout:t,stderr:i}=await(s=r,o={cwd:e},new Promise((e,t)=>{d.exec(s,o,(r,s,o)=>{r&&t({error:r,stdout:s,stderr:o}),e({stdout:s,stderr:o})})}));i&&(v().appendLine(i),m());const n=[];if(t){const e=t.split(/\r{0,1}\n/);let r=!1,s=!1;for(const t of e)if(0!==t.length)if(r||s){if(r&&!s)if(0===t.indexOf("Tasks run in the order specified"))s=!0;else{const e=/^\s*(\S.*\S) \S/g.exec(t);if(e&&2===e.length){const t=e[1],r={type:"grunt",task:t},s="grunt",o={cwd:this.workspaceFolder.uri.fsPath},i=-1===t.indexOf(" ")?new u.Task(r,this.workspaceFolder,t,s,new u.ShellExecution(`${await this._gruntCommand} ${t}`,o)):new u.Task(r,this.workspaceFolder,t,s,new u.ShellExecution(`${await this._gruntCommand} "${t}"`,o));n.push(i);const a=t.toLowerCase();p(a)?i.group=u.TaskGroup.Build:g(a)&&(i.group=u.TaskGroup.Test)}}}else 0===t.indexOf("Available tasks")&&(r=!0)}return n}catch(e){const r=v();return e.stderr&&r.appendLine(e.stderr),e.stdout&&r.appendLine(e.stdout),r.appendLine(u.l10n.t("Auto detecting Grunt for folder {0} failed with error: {1}', this.workspaceFolder.name, err.error ? err.error.toString() : 'unknown")),m(),t}var s,o}dispose(){this.promise=void 0,this.fileWatcher&&this.fileWatcher.dispose()}}class T{taskProvider;detectors=new Map;constructor(){}start(){const e=u.workspace.workspaceFolders;e&&this.updateWorkspaceFolders(e,[]),u.workspace.onDidChangeWorkspaceFolders(e=>this.updateWorkspaceFolders(e.added,e.removed)),u.workspace.onDidChangeConfiguration(this.updateConfiguration,this)}dispose(){this.taskProvider&&(this.taskProvider.dispose(),this.taskProvider=void 0),this.detectors.clear()}updateWorkspaceFolders(e,t){for(const e of t){const t=this.detectors.get(e.uri.toString());t&&(t.dispose(),this.detectors.delete(e.uri.toString()))}for(const t of e){const e=new P(t,_(t.uri.fsPath));this.detectors.set(t.uri.toString(),e),e.isEnabled()&&e.start()}this.updateProvider()}updateConfiguration(){for(const e of this.detectors.values())e.dispose(),this.detectors.delete(e.workspaceFolder.uri.toString());const e=u.workspace.workspaceFolders;if(e)for(const t of e)if(!this.detectors.has(t.uri.toString())){const e=new P(t,_(t.uri.fsPath));this.detectors.set(t.uri.toString(),e),e.isEnabled()&&e.start()}this.updateProvider()}updateProvider(){if(!this.taskProvider&&this.detectors.size>0){const e=this;this.taskProvider=u.tasks.registerTaskProvider("grunt",{provideTasks:()=>e.getTasks(),resolveTask:t=>e.getTask(t)})}else this.taskProvider&&0===this.detectors.size&&(this.taskProvider.dispose(),this.taskProvider=void 0)}getTasks(){return this.computeTasks()}computeTasks(){if(0===this.detectors.size)return Promise.resolve([]);if(1===this.detectors.size)return this.detectors.values().next().value.getTasks();{const e=[];for(const t of this.detectors.values())e.push(t.getTasks().then(e=>e,()=>[]));return Promise.all(e).then(e=>{const t=[];for(const r of e)r&&r.length>0&&t.push(...r);return t})}}async getTask(e){if(0!==this.detectors.size){if(1===this.detectors.size)return this.detectors.values().next().value.getTask(e);if(e.scope!==u.TaskScope.Workspace&&e.scope!==u.TaskScope.Global&&e.scope){const t=this.detectors.get(e.scope.uri.toString());if(t)return t.getTask(e)}}}}},317:e=>{e.exports=require("child_process")},398:e=>{e.exports=require("vscode")},896:e=>{e.exports=require("fs")},928:e=>{e.exports=require("path")}},t={},r=function r(s){var o=t[s];if(void 0!==o)return o.exports;var i=t[s]={exports:{}};return e[s].call(i.exports,i,i.exports,r),i.exports}(184),s=exports;for(var o in r)s[o]=r[o];r.__esModule&&Object.defineProperty(s,"__esModule",{value:!0})})();
//# sourceMappingURL=https://main.vscode-cdn.net/sourcemaps/1e3c50d64110be466c0b4a45222e81d2c9352888/extensions/grunt/dist/main.js.map