forked from localnerve/react-pwa-reference
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostinstall.js
38 lines (35 loc) · 1.01 KB
/
postinstall.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
30
31
32
33
34
35
36
37
38
/***
* Copyright (c) 2016 - 2018 Alex Grant (@localnerve), LocalNerve LLC
* Copyrights licensed under the BSD License. See the accompanying LICENSE file for terms.
*
* The universal postinstall script.
*/
/* global require, console */
/*eslint-disable no-console */
'use strict';
const fs = require('fs');
/**
* Create the appliction symlink, fail quietly if exists.
* Setting up 'src' is only required for local development/running.
* Setting up 'output' is only required for the remote host deployment.
*
* @param {String} type - one of 'src' or 'output'.
*/
function applicationSymLink (type) {
try {
fs.symlinkSync(
'../application',
`./${type}/node_modules/application`,
'dir'
);
console.log(`*** Successfully setup ${type} application symlink ***`);
} catch(e){
if (e.code !== 'EEXIST') {
console.error(
`*** FAILED to create ${type} symlink. This might be ok. ***
${e}`
);
}
}
}
['src', 'output'].forEach((type) => applicationSymLink(type));