-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall-git-packages.js
29 lines (24 loc) · 981 Bytes
/
install-git-packages.js
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
var packages = require('./github-packages');
var del = require('del');
var shell = require('shelljs');
var path = require('path');
var pathToLib = path.join(__dirname, './lib/from-github');
var chalk = require('chalk');
var githubPrefix = 'http://www.github.com/';
function log(msg) {
var now = 'GHP - [' + new Date().toLocaleTimeString() + ']';
console.log(chalk.gray(now), msg);
}
del.sync(pathToLib);
log('cleaning lib folder ' + chalk.yellow(pathToLib));
shell.exec('mkdir ' + pathToLib);
Object.keys(packages)
.forEach(function (packagePath) {
var fullPath = githubPrefix + packagePath;
var dirName = packagePath.split('/')[1];
log('cloning ' + chalk.green(packagePath) + ' from ' + chalk.green(fullPath));
shell.exec('git clone ' + fullPath, {cwd: pathToLib});
log('removing .git files in ' + chalk.green(dirName));
console.log('.git - ', path.join(pathToLib, dirName, '/.git'));
del.sync(path.join(pathToLib, dirName, '/.git'));
});