本文整理汇总了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;未经允许,请勿转载。 |
请发表评论