1 | const Command = require('../base')
|
2 | const renderShortDesc = require('../utils/renderShortDescription')
|
3 | const { track } = require('../utils/telemetry')
|
4 |
|
5 | class UnlinkCommand extends Command {
|
6 | async run() {
|
7 | const { site, state } = this.netlify
|
8 | const siteId = site.get('siteId')
|
9 |
|
10 | if (!siteId) {
|
11 | this.log(`Folder is not linked to a Netlify site`)
|
12 | return this.exit()
|
13 | }
|
14 |
|
15 | let siteData = {}
|
16 | try {
|
17 | siteData = await this.netlify.api.getSite({ siteId })
|
18 | } catch (e) {
|
19 |
|
20 | }
|
21 |
|
22 | state.delete('siteId')
|
23 |
|
24 | await track('sites_unlinked', {
|
25 | siteId: siteData.id || siteId,
|
26 | })
|
27 |
|
28 | this.log(`Unlinked ${site.configPath} from ${siteData ? siteData.name : siteId}`)
|
29 | }
|
30 | }
|
31 |
|
32 | UnlinkCommand.description = `${renderShortDesc('Unlink a local folder from a Netlify site')}`
|
33 |
|
34 | module.exports = UnlinkCommand
|