本文整理汇总了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
});
});
});
});
示例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();
});
});
}
});
}
示例3: callback
pathExists: (path, callback) => {
fs.access(path, fs.constants.F_OK, (err) => {
callback(null, {
exists: err ? false : true
});
});
},
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
});
}
示例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);
}
});
});
示例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',
});
}
}