當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript glob.Glob類代碼示例

本文整理匯總了TypeScript中glob.Glob的典型用法代碼示例。如果您正苦於以下問題:TypeScript Glob類的具體用法?TypeScript Glob怎麽用?TypeScript Glob使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Glob類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: sendNewFileList

        (function() {
            const cwd = q.directory;
            const mg = new glob.Glob('**', { cwd, dot: true }, (e, newList) => {
                if (e) {
                    console.error('Globbing error:', e);
                }

                let list = newList.map(nl => {
                    let p = path.resolve(cwd, nl);
                    let type = mg.cache[p] && mg.cache[p] == 'FILE' ? types.FilePathType.File : types.FilePathType.Dir;
                    return {
                        filePath: fsu.consistentPath(p),
                        type,
                    }
                });

                // Initial search complete!
                completed = true;
                list.forEach(entry => liveList[entry.filePath] = entry.type);
                sendNewFileList();
            });
            /** Still send the listing while globbing so user gets immediate feedback */
            mg.on('match', (match) => {
                let p = path.resolve(cwd, match);
                if (mg.cache[p]) {
                    liveList[fsu.consistentPath(p)] = mg.cache[p] == 'FILE' ? types.FilePathType.File : types.FilePathType.Dir;
                    sendNewFileListThrottled();
                }
            });
        })();
開發者ID:J1978,項目名稱:alm,代碼行數:30,代碼來源:fileListingWorker.ts

示例2: myActivate

    function myActivate() {

        // Show loading info box
        let info = vscode.window.showQuickPick([emptyItem], { matchOnDescription: false, placeHolder: "Finding files... Please wait. (Press escape to cancel)" });
        info.then(
            (value?: any) => {
                myGlob.pause();
                paused = true;
            },
            (rejected?: any) => {
                myGlob.pause();
                paused = true;
            }
        );

        // Search for files
        if (paused) {
            paused = false;
            myGlob.resume();
        } else {
            myGlob = new Glob(workspacePath + "/**/*.*",
                { ignore: configuration.get("ignore") },
                function(err, files) {
                    if (err) {
                        return;
                    }

                    items = files;
                    vscode.commands.executeCommand("extension.relativePath");
                });
            myGlob.on("end", function() {
                paused = false;
            });
        }
    }
開發者ID:platonicvizard,項目名稱:RelativePath,代碼行數:35,代碼來源:extension.ts

示例3: checkGlobbingError

        (function() {

            /** These things are coming on a mac for some reason */
            const ignoreThisPathThatGlobGivesForUnknownReasons = (filePath:string) => {
                return filePath.includes('0.0.0.0') || (filePath.includes('[object Object]'))
            }

            const cwd = q.directory;
            const mg = new glob.Glob('**', { cwd, dot: true }, (e, newList) => {
                if (e) {
                    checkGlobbingError(e);
                    if (abortGlobbing) {
                        mg.abort();
                        // if we don't exit then glob keeps globbing + erroring despite mg.abort()
                        process.exit();
                        return;
                    }
                    console.error('Globbing error:', e);
                }

                let list = newList.map(nl => {
                    let p = fsu.resolve(cwd, nl);
                    // NOTE: the glob cache also uses consistent path even on windows, hence `fsu.resolve` ^ :)
                    let type = mg.cache[p] && mg.cache[p] == 'FILE' ? types.FilePathType.File : types.FilePathType.Dir;

                    if (ignoreThisPathThatGlobGivesForUnknownReasons(nl)) {
                        // console.log(nl, mg.cache[p]); /// DEBUG
                        return null;
                    }

                    return {
                        filePath: fsu.consistentPath(p),
                        type,
                    }
                }).filter(x=>!!x);

                // Initial search complete!
                completed = true;
                list.forEach(entry => liveList[entry.filePath] = entry.type);
                sendNewFileList();
            });
            /** Still send the listing while globbing so user gets immediate feedback */
            mg.on('match', (match) => {
                let p = fsu.resolve(cwd, match);
                if (mg.cache[p]) {
                    if (ignoreThisPathThatGlobGivesForUnknownReasons(match)) {
                        return;
                    }
                    liveList[fsu.consistentPath(p)] = mg.cache[p] == 'FILE' ? types.FilePathType.File : types.FilePathType.Dir;
                    sendNewFileListThrottled();
                }
            });
        })();
開發者ID:hsyngkby,項目名稱:alm,代碼行數:53,代碼來源:fileListingWorker.ts

示例4: return

		return (() => {
			let projectDir = this.$projectData.projectDir;
			let isNodeModulesModified = false;
			let nodeModulesPath = path.join(projectDir, constants.NODE_MODULES_FOLDER_NAME);
			let nodeModules: any = {};

			if (lastModifiedTime) {
				let future = new Future();

				let match = new glob.Glob("node_modules/**", {
					cwd: projectDir,
					follow: true,
					stat: true
				}, (er: Error, files: string[]) => {
					fiberBootstrap.run(() => {
						this.$lockfile.lock().wait();
						if (er) {
							if (!future.isResolved()) {
								future.throw(er);
							}

							this.$lockfile.unlock().wait();
							match.abort();
							return;
						}
						for (let i = 0, l = files.length; i < l; i++) {
							let file = files[i],
								resolvedPath = path.join(projectDir, file),
								relativePath = path.relative(projectDir, resolvedPath);
							let stat = match.statCache[resolvedPath] || match.statCache[relativePath];
							if (!stat) {
								match.statCache[resolvedPath] = stat = this.$fs.getFsStats(resolvedPath).wait();
							}

							if (stat.mtime <= lastModifiedTime) {
								continue;
							}
							if (file === constants.NODE_MODULES_FOLDER_NAME) {
								isNodeModulesModified = true;
								this.$lockfile.unlock().wait();
								match.abort();
								if (!future.isResolved()) {
									future.return();
								}
								return;
							}
							let rootModuleName = path.normalize(file).split(path.sep)[1];
							let rootModuleFullPath = path.join(nodeModulesPath, rootModuleName);
							nodeModules[rootModuleFullPath] = rootModuleFullPath;
						}

						this.$lockfile.unlock().wait();
					});
				});
				match.on("end", () => {
					if (!future.isResolved()) {
						let intervalId = setInterval(() => {
							fiberBootstrap.run(() => {
								if (!this.$lockfile.check().wait() || future.isResolved()) {
									if(!future.isResolved()) {
										future.return();
									}
									clearInterval(intervalId);
								}
							});
						}, 100);
					}
				});

				future.wait();
			}

			if (isNodeModulesModified && this.$fs.exists(absoluteOutputPath).wait()) {
				let currentPreparedTnsModules = this.$fs.readDirectory(absoluteOutputPath).wait();
				let tnsModulesPath = path.join(projectDir, constants.APP_FOLDER_NAME, constants.TNS_MODULES_FOLDER_NAME);
				if (!this.$fs.exists(tnsModulesPath).wait()) {
					tnsModulesPath = path.join(projectDir, constants.NODE_MODULES_FOLDER_NAME, constants.TNS_CORE_MODULES_NAME);
				}
				let tnsModulesInApp = this.$fs.readDirectory(tnsModulesPath).wait();
				let modulesToDelete = _.difference(currentPreparedTnsModules, tnsModulesInApp);
				_.each(modulesToDelete, moduleName => this.$fs.deleteDirectory(path.join(absoluteOutputPath, moduleName)).wait());
			}

			if (!lastModifiedTime || isNodeModulesModified) {
				this.listModules(nodeModulesPath, nodeModules);
			}

			return nodeModules;
		}).future<any>()();
開發者ID:Emat12,項目名稱:nativescript-cli,代碼行數:89,代碼來源:builder.ts


注:本文中的glob.Glob類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。