1 | #! /usr/bin/env node
|
2 |
|
3 | var fs = require('fs-extra')
|
4 | var path = require('path')
|
5 |
|
6 | var currentPath = process.cwd()
|
7 | var workspacePath = path.join(currentPath, 'workspace')
|
8 | var destinationDir = path.join(currentPath, '../../../workspace')
|
9 |
|
10 |
|
11 | if (~currentPath.indexOf('node_modules')) {
|
12 | fs.stat(destinationDir, (err, stats) => {
|
13 | if (err && err.code && err.code === 'ENOENT') {
|
14 | fs.copy(workspacePath, destinationDir, { overwrite: false }, (err) => {
|
15 | if (err) return console.error(err)
|
16 |
|
17 | fs.move(destinationDir + '/collections/vjoin', destinationDir + '/collections/1.0', { overwrite: false }, (err) => {
|
18 | fs.move(destinationDir + '/collections/1.0/testdb', destinationDir + '/collections/1.0/library', { overwrite: false }, (err) => {
|
19 | fs.remove(destinationDir + '/collections/vtest', err => {
|
20 | fs.remove(destinationDir + '/endpoints/v1', err => {
|
21 | fs.remove(destinationDir + '/media', err => {
|
22 | fs.remove(destinationDir + '/hooks/layout.js', err => {
|
23 | console.log('API: workspace directory created at', destinationDir)
|
24 | })
|
25 | })
|
26 | })
|
27 | })
|
28 | })
|
29 | })
|
30 | })
|
31 | } else {
|
32 | console.log('API: Refusing to overwrite existing workspace directory')
|
33 | }
|
34 | })
|
35 | }
|