| Total Complexity | 1 |
| Complexity/F | 1 |
| Lines of Code | 23 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import {writeFileSync} from 'fs' |
||
| 2 | import Nginx from '../services/nginx' |
||
| 3 | import nginxSiteConfig from '../templates/nginxSite' |
||
| 4 | import {ensureDirectoryExists} from '../utils/filesystem' |
||
| 5 | import {getConfig, jaleSitesPath} from '../utils/jale' |
||
| 6 | |||
| 7 | class SitesController { |
||
| 8 | |||
| 9 | executeLink = async (): Promise<void> => { |
||
| 10 | const config = await getConfig() |
||
| 11 | const domain = process.cwd().substring(process.cwd().lastIndexOf('/') + 1) |
||
| 12 | const hostname = `${domain}.${config.domain}` |
||
| 13 | |||
| 14 | await ensureDirectoryExists(jaleSitesPath) |
||
| 15 | |||
| 16 | await writeFileSync(`${jaleSitesPath}/${hostname}.conf`, nginxSiteConfig(hostname, process.cwd())) |
||
| 17 | |||
| 18 | await (new Nginx()).reload |
||
| 19 | } |
||
| 20 | |||
| 21 | } |
||
| 22 | |||
| 23 | export default SitesController |