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


TypeScript fs-extra.access函數代碼示例

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


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

示例1: getPotentialCWLClassFromFile

        getPotentialCWLClassFromFile(filePath, (err, cwlClass) => {
            if (err) return callback(err);

            let isReadable = true;
            let isWritable = true;

            fs.access(filePath, fs.constants.R_OK, (err) => {
                if (err) isReadable = false;

                fs.access(filePath, fs.constants.W_OK, (err) => {
                    if (err) isWritable = false;

                    callback(null, {
                        type: cwlClass,
                        path: filePath,
                        name: path.basename(filePath),
                        isDir: stats.isDirectory(),
                        isFile: stats.isFile(),
                        dirname: path.dirname(filePath),
                        language: stats.isFile() ? filePath.split(".").pop() : "",
                        isWritable,
                        isReadable
                    });
                });
            });

        });
開發者ID:hmenager,項目名稱:composer,代碼行數:27,代碼來源:fs.controller.ts

示例2: paste

function paste(data: CmdData): void {
    if (!cutCopyFileMemory) {
        codeFileNav.showFileList();

        return;
    }

    const method = cutCopyCmdMemory === 'cut' ? fs.move : fs.copy;
    let newPath: string = path.join(data.cwd, cutCopyFileMemory.name);

    fs.access(newPath, err => {
        if (err) {
            method(cutCopyFileMemory.path, newPath, err => {
                cutCopyCmdMemory = undefined;

                if (codeFileNav.checkError(err)) { return; }

                codeFileNav.showFileList();
            });
        } else {
            getNewPath('The destination already exists, enter another name', data.cwd, newPath => {
                method(cutCopyFileMemory.path, newPath, err => {
                    cutCopyCmdMemory = undefined;

                    if (codeFileNav.checkError(err)) { return; }

                    codeFileNav.showFileList();
                });
            });
        }
    });
}
開發者ID:jakelucas,項目名稱:code-file-nav,代碼行數:32,代碼來源:commands.ts

示例3: callback

 pathExists: (path, callback) => {
     fs.access(path, fs.constants.F_OK, (err) => {
         callback(null, {
             exists: err ? false : true
         });
     });
 },
開發者ID:hmenager,項目名稱:composer,代碼行數:7,代碼來源:fs.controller.ts

示例4: isExecutable

export async function isExecutable(path: string): Promise<boolean> {
	try {
		await fs.access(path, fs.constants.X_OK);
		return true;
	} catch (e) {
		return false;
	}
}
開發者ID:hbenl,項目名稱:vscode-firefox-debug,代碼行數:8,代碼來源:fs.ts

示例5: canWrite

 async canWrite(uri: string): Promise<boolean> {
     try {
         const path = FileUri.fsPath(uri);
         await fs.access(path, fs.constants.W_OK);
         return true;
     } catch {
         return false;
     }
 }
開發者ID:crapo,項目名稱:sadlos2,代碼行數:9,代碼來源:node-filesystem-ext.ts

示例6: nodeModulesAlreadyExist

async function nodeModulesAlreadyExist(): Promise<boolean> {
    const logger = getLogger();
    logger.trace('Checking node_modules');

    try {
        await fsExtra.access(nodeModules);
        logger.trace('\'node_modules\' directory already exists');
        return true
    } catch (err) {
        logger.trace('Node_modules not found');
        return false;
    }
}
開發者ID:mutantcornholio,項目名稱:veendor,代碼行數:13,代碼來源:index.ts

示例7: push

export function push(hash:string, options: GitLfsOptions, cacheDir: string) {
    const repoDir = path.resolve(cacheDir, 'repo');
    const archivePath = path.resolve(
        repoDir,
        `${hash}.tar${tarWrapper.compression[options.compression]}`
    );

    const tagName = `veendor-${hash}`;

    return fsExtra.access(repoDir, fsExtra.constants.F_OK)
        .then(() => {
            return gitWrapper.fetch(repoDir);
        }, () => {
            return gitWrapper.clone(options.repo, repoDir);
        })
        .then(() => {
            return gitWrapper.checkout(repoDir, options.defaultBranch)
        })
        .then(() => {
            return gitWrapper.resetToRemote(repoDir, options.defaultBranch)
        })
        .then(() => {
            return tarWrapper.createArchive(archivePath, [path.resolve(
                process.cwd(),
                'node_modules'
            )], options.compression);
        })
        .then(() => {
            return gitWrapper.add(repoDir, [archivePath], true)
        })
        .then(() => {
            return gitWrapper.commit(repoDir, hash)
        })
        .then(() => {
            return gitWrapper.tag(repoDir, tagName)
        })
        .then(() => {
            return gitWrapper.push(repoDir, tagName)
        })
        .catch(error => {
            if (error instanceof gitWrapper.RefAlreadyExistsError) {
                throw new errors.BundleAlreadyExistsError();
            }

            throw error;
        });
}
開發者ID:mutantcornholio,項目名稱:veendor,代碼行數:47,代碼來源:git-lfs.ts

示例8: removeInvalidChars

    vscode.window.showInputBox({ placeHolder }).then(newName => {
        newName = removeInvalidChars(newName);

        if (!newName) {
            codeFileNav.showFileList();

            return;
        }

        const newPath: string = path.join(dir, newName);

        fs.access(newPath, err => {
            if (err) {
                callback(newPath);
            } else {
                getNewPath('The destination already exists, enter another name', dir, callback);
            }
        });
    });
開發者ID:jakelucas,項目名稱:code-file-nav,代碼行數:19,代碼來源:commands.ts

示例9: moveApp

  async moveApp(appPath: string, targetApplicationPath: string, spinner: OraImpl, copyInstead = false) {
    let writeAccess = true;
    try {
      await fs.access('/Applications', fs.constants.W_OK);
    } catch (err) {
      writeAccess = false;
    }

    if (await fs.pathExists(targetApplicationPath)) {
      spinner.fail();
      throw `The application "${path.basename(targetApplicationPath)}" appears to already exist in /Applications.`;
    }

    const moveCommand = `${copyInstead ? 'cp -r' : 'mv'} "${appPath}" "${targetApplicationPath}"`;
    if (writeAccess) {
      await pify(exec)(moveCommand);
    } else {
      await pify(sudo.exec)(moveCommand, {
        name: 'Electron Forge',
      });
    }
  }
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:22,代碼來源:InstallerDarwin.ts


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