1 | 'use strict'
|
2 |
|
3 | const { isDirectory } = require('../../utils/fs')
|
4 |
|
5 | async function verifyFilesPath ([config, installConfig]) {
|
6 | const { filesPath, name } = installConfig
|
7 | const errorPrefix = `Template '${name}'`
|
8 |
|
9 | try {
|
10 | if (!await isDirectory(filesPath)) {
|
11 | throw new Error(`${errorPrefix} files path is not a directory`)
|
12 | }
|
13 | } catch (error) {
|
14 | if (error.code === 'ENOENT') {
|
15 | throw new Error(`${errorPrefix} files directory Not Found`)
|
16 | }
|
17 | if (error.code === 'EACCES') {
|
18 | throw new Error(`${errorPrefix} files directory Permission Denied`)
|
19 | }
|
20 | throw error
|
21 | }
|
22 |
|
23 | return [config, installConfig]
|
24 | }
|
25 |
|
26 | module.exports = exports = verifyFilesPath
|