本文整理匯總了TypeScript中fs.chmod函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript chmod函數的具體用法?TypeScript chmod怎麽用?TypeScript chmod使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了chmod函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
fs.exists(newDir, function (params:any, status:any) {
console.log(params);
if (status !== true) {
fs.mkdir(newDir, function () {});
fs.chmod(newDir, '777', function () {
});
} else {
fs.chmod(newDir, '777', function () {
});
}
});
示例2: async
let disposable = commands.registerCommand('cake.bootstrapper', async () => {
//check if there is an open folder in workspace
if (workspace.rootPath === undefined) {
window.showErrorMessage('You have not yet opened a folder.');
return;
}
let bootstrapper = new Bootstrapper(process.platform);
var buildFilePath = path.join(workspace.rootPath, bootstrapper.buildFilename);
//check if there is a
if (fs.existsSync(buildFilePath)) {
var option = await window.showWarningMessage(`Overwrite the existing ${bootstrapper.buildFilename} file in this folder ?`, 'Overwrite');
if (option !== 'Overwrite')
return;
}
var file = fs.createWriteStream(buildFilePath);
var result = await bootstrapper.download(file);
if (result) {
if (process.platform !== 'win32')
fs.chmod(buildFilePath, 0o755);
window.showInformationMessage('Cake bootstrapper downloaded successfully');
} else {
window.showErrorMessage('Error downloading Cake bootstrapper');
}
});
示例3: function
export const makePathExecutable = function (runPath: string, cb: ErrnoExceptionType) {
if (runPath) {
fs.chmod(runPath, 0o777, cb);
}
else {
process.nextTick(cb);
}
};
示例4: reject
const finish = (error?: Error) => {
if (!finished) {
finished = true;
// in error cases, pass to callback
if (error) {
return reject(error);
}
// we need to explicitly chmod because of https://github.com/nodejs/node/issues/1104
fs.chmod(target, mode, error => error ? reject(error) : resolve());
}
};
示例5: checkFileExists
checkFileExists(file).then((exists: boolean) => {
if (exists) {
fs.chmod(file, '755', (err: NodeJS.ErrnoException) => {
if (err) {
reject(err);
return;
}
resolve();
});
} else {
getOutputChannel().appendLine("");
getOutputChannel().appendLine(`Warning: Expected file ${file} is missing.`);
resolve();
}
});
示例6: downloadKubectl
export async function downloadKubectl(version: string) : Promise<string> {
var kubectlURL = getkubectlDownloadURL(version);
var cachedToolpath = toolLib.findLocalTool(kubectlToolName, version);
if(!cachedToolpath) {
try {
var KubectlDownloadPath = await toolLib.downloadTool(getkubectlDownloadURL(version));
} catch(exception) {
throw new Error(tl.loc("DownloadKubectlFailedFromLocation", getkubectlDownloadURL(version), exception));
}
cachedToolpath = await toolLib.cacheFile(KubectlDownloadPath, kubectlToolName + getExecutableExtention() , kubectlToolName, version);
}
var kubectlPath = path.join(cachedToolpath, kubectlToolName + getExecutableExtention());
fs.chmod(kubectlPath, "777");
return kubectlPath;
}
示例7:
fs.access(this.activeTextEditor.document.fileName, fs.W_OK, (accessErr) => {
if (accessErr) {
if (this.arguments.bang) {
fs.chmod(this.activeTextEditor.document.fileName, 666, (e) => {
if (e) {
modeHandler.setupStatusBarItem(e.message);
} else {
this.save(modeHandler);
}
});
} else {
modeHandler.setupStatusBarItem(accessErr.message);
}
} else {
this.save(modeHandler);
}
});
示例8: getKubectl
private async getKubectl() : Promise<string> {
let versionOrLocation = tl.getInput("versionOrLocation");
if( versionOrLocation === "location") {
let pathToKubectl = tl.getPathInput("specifyLocation", true, true);
fs.chmod(pathToKubectl, "777");
return pathToKubectl;
}
else if(versionOrLocation === "version") {
tl.debug(tl.loc("DownloadingClient"));
var kubectlPath = path.join(this.userDir, "kubectl") + this.getExecutableExtention();
let versionSpec = tl.getInput("versionSpec");
let checkLatest: boolean = tl.getBoolInput('checkLatest', false);
return utils.getKubectlVersion(versionSpec, checkLatest).then((version) => {
return utils.downloadKubectl(version, kubectlPath);
})
}
}
示例9: installCakeBootstrapper
export async function installCakeBootstrapper()
{
// Let the user select the bootstrapper.
var info = await window.showQuickPick(CakeBootstrapper.getBootstrappers(), {
"placeHolder": "Select the bootstrapper that you want to install",
"matchOnDetail": true,
"matchOnDescription": true
});
if (!info) {
return;
}
// Check if there is an open folder in workspace
if (workspace.rootPath === undefined) {
window.showErrorMessage('You have not yet opened a folder.');
return;
}
// Create the bootstrapper from the platform.
let bootstrapper = new CakeBootstrapper(info);
// Does the bootstrapper already exist?
var buildFilePath = bootstrapper.getTargetPath();
if (fs.existsSync(buildFilePath)) {
var message = `Overwrite the existing \'${info.fileName}\' file in this folder?`;
var option = await window.showWarningMessage(message, 'Overwrite');
if (option !== 'Overwrite') {
return;
}
}
// Download the bootstrapper and save it to disk.
var file = fs.createWriteStream(buildFilePath);
var result = await bootstrapper.download(file);
if (result) {
if (process.platform !== 'win32' && info.posix) {
fs.chmod(buildFilePath, 0o755);
}
window.showInformationMessage('Cake bootstrapper downloaded successfully.');
} else {
window.showErrorMessage('Error downloading Cake bootstrapper.');
}
}
示例10: execute
async execute(vimState: VimState): Promise<void> {
if (this.arguments.opt) {
Message.ShowError('Not implemented.');
return;
} else if (this.arguments.file) {
Message.ShowError('Not implemented.');
return;
} else if (this.arguments.append) {
Message.ShowError('Not implemented.');
return;
} else if (this.arguments.cmd) {
Message.ShowError('Not implemented.');
return;
}
if (vimState.editor.document.isUntitled) {
await vscode.commands.executeCommand('workbench.action.files.save');
return;
}
try {
await util.promisify(fs.access)(vimState.editor.document.fileName, fs.constants.W_OK);
return this.save(vimState);
} catch (accessErr) {
if (this.arguments.bang) {
fs.chmod(vimState.editor.document.fileName, 666, e => {
if (!e) {
return this.save(vimState);
}
StatusBar.SetText(e.message, vimState.currentMode, vimState.isRecordingMacro, true, true);
return;
});
} else {
StatusBar.SetText(
accessErr.message,
vimState.currentMode,
vimState.isRecordingMacro,
true,
true
);
}
}
}