copy.js
1.8 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
45
/**
* React Starter Kit (http://www.reactstarterkit.com/)
*
* Copyright © 2014-2015 Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import path from 'path';
import Promise from 'bluebird';
import del from 'del';
import fs from './lib/fs';
import getSettings from '../server/boot/config';
/**
* Copies static files such as robots.txt, favicon.ico to the
* output (build) folder.
async*/
async function copy() {
const ncp = Promise.promisify(require('ncp'));
// await ncp(path.join(__dirname, '..','src','public'), path.join(__dirname, '..','build','public'));
// await ncp(path.join(__dirname, '..','src','content'),path.join(__dirname, '..','build','content'));
// await ncp(path.join(__dirname, '..','package.json'), path.join(__dirname, '..','build','package.json'));
await del(['.tmp', 'build/*', '!build/.git', 'server/views/index.ejs'], { dot: true });
await fs.makeDir('build/public');
const prefix = getSettings().defaults.prefix || '/';
await fs.makeDir('build/public' + prefix + 'img');
await fs.makeDir('build/public' + prefix + 'my_img');
await fs.makeDir('build/public' + prefix + 'js');
await fs.makeDir('build/public' + prefix + 'css');
await Promise.all([
ncp('./src/public', './build/public'),
ncp('./src/content', './build/content'),
ncp('./package.json', './build/package.json'),
ncp('./temp_build/public', './build/public'),
ncp('./src/public/img', './build/public' + prefix + 'img'),
ncp('./src/public/my_img', './build/public' + prefix + 'my_img'),
ncp('./src/public/js', './build/public' + prefix + 'js'),
ncp('./src/public/css', './build/public' + prefix + 'css'),
ncp('./temp_build/index.ejs', './server/views/index.ejs')
]);
}
export default copy;