-
-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathinstall-folder-permissions.js
33 lines (27 loc) · 1.07 KB
/
install-folder-permissions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
const fs = require('node:fs/promises');
const constants = require('constants');
const chalk = require('chalk');
const errors = require('../../../errors');
const checkDirectoryAndAbove = require('./check-directory');
const taskTitle = 'Checking current folder permissions';
async function installFolderPermissions(ctx) {
try {
await fs.access(process.cwd(), constants.R_OK | constants.W_OK);
} catch (_) {
throw new errors.SystemError({
message: `The directory ${process.cwd()} is not writable by your user. You must grant write access and try again.`,
help: `${chalk.green('https://ghost.org/docs/install/ubuntu/#create-a-directory')}`,
task: taskTitle
});
}
if (ctx.local || !ctx.system.platform.linux || (ctx.argv && ctx.argv['setup-linux-user'] === false)) {
return;
}
return checkDirectoryAndAbove(process.cwd(), 'run `ghost install`', taskTitle);
}
module.exports = {
title: taskTitle,
task: installFolderPermissions,
category: ['install', 'update', 'start']
};