本文整理匯總了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',
});
}
}