-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.js
19 lines (16 loc) · 663 Bytes
/
install.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const fs = require('fs');
const path = require('path');
const packageJson = require('./package.json');
const filePath = path.join(packageJson.main);
function mkFullPathSync(absolutePath, permissions = '0755') {
absolutePath.split(path.sep).reduce((origin, folder) => {
const next = `${origin}${folder}${path.sep}`;
if (!fs.existsSync(next)) fs.mkdirSync(next, permissions);
return next;
}, '');
}
mkFullPathSync(`../../../${filePath}`);
fs.cp(filePath, `../../../${filePath}`, { recursive: true }, (err) => {
if (err) fs.writeFileSync(`error.txt`, err, 'utf8');
fs.writeFileSync(`done.txt`, `${filePath} => ../../${filePath}`, 'utf8');
});