forked from netlify/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunlink.js
More file actions
44 lines (35 loc) · 1.01 KB
/
Copy pathunlink.js
File metadata and controls
44 lines (35 loc) · 1.01 KB
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
34
35
36
37
38
39
40
41
42
43
44
const Command = require('../utils/command')
const { track } = require('../utils/telemetry')
class UnlinkCommand extends Command {
async run() {
const { site, state } = this.netlify
const siteId = site.id
if (!siteId) {
this.log(`Folder is not linked to a Netlify site. Run 'netlify link' to link it`)
return this.exit()
}
await this.config.runHook('analytics', {
eventName: 'command',
payload: {
command: 'unlink',
},
})
let siteData = {}
try {
siteData = await this.netlify.api.getSite({ siteId })
} catch (error) {
// ignore errors if we can't get the site
}
state.delete('siteId')
await track('sites_unlinked', {
siteId: siteData.id || siteId,
})
if (site) {
this.log(`Unlinked ${site.configPath} from ${siteData ? siteData.name : siteId}`)
} else {
this.log('Unlinked site')
}
}
}
UnlinkCommand.description = `Unlink a local folder from a Netlify site`
module.exports = UnlinkCommand