forked from himynameisdave/postcss-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-new-plugin.js
More file actions
42 lines (37 loc) · 1.21 KB
/
Copy pathadd-new-plugin.js
File metadata and controls
42 lines (37 loc) · 1.21 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
const inquirer = require('inquirer');
const prompts = require('./data/new-plugin-prompts.js');
const writePlugins = require('./utils/write-plugins.js');
const plugins = require('../plugins.json');
// Copy of plugins so as to keep original list immutable
const updatedPlugins = plugins;
// Step One: Show the banner
console.log(require('./data/banner'));
// Step Two: Do Prompts
(function addNewPlugin() {
// doPluginPrompts()
inquirer.prompt(prompts)
.then((answers) => {
// Add the new plugin to the list of updated plugins
const {
name, description, author, url, tags,
} = answers;
updatedPlugins.push({
name,
description,
author,
url,
tags,
stars: 0,
});
// Let the user know we are adding the plugin to the list for them
console.log(`Adding the following plugin to the list:\n - ${name}`);
// Step 3: Add another plugin if we need to
if (answers.addAnother === true) {
return addNewPlugin();
}
// If we don't need to add a plugin, write the list of updated plugins
return writePlugins(updatedPlugins, 'plugins.json');
})
.then(console.log)
.catch(console.warn);
}());