This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playground.js
60 lines (51 loc) · 1.53 KB
/
playground.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const FS = require('fs');
const { execSync, spawnSync } = require('child_process');
const playgroundDirectoryExist = () => {
try {
FS.accessSync('./.playground');
return true;
} catch (e) {
return false;
}
};
const createPlaygroundDirectory = () => {
console.log('Creating playground directory...');
FS.mkdirSync('./.playground');
};
const cloneProjectSampleInPlayground = () => {
console.log('Cloning project sample in playground...');
execSync('cd ./.playground && git clone https://github.com/RiceCooker-dev/Lary-Scafold.git');
};
const installProjectSampleInPlayground = () => {
console.log('Installing project sample in playground...');
execSync('cd ./.playground/Lary-Scafold && yarn');
};
const compileLibrary = () => {
console.log('Compiling library...');
execSync('yarn rollup');
};
const loadLibInPlayground = () => {
console.log('Loading library in playground...');
execSync(
'rm -rdf ./.playground/Lary-Scafold/node_modules/lary/dist && cp -r dist ./.playground/Lary-Scafold/node_modules/lary/dist'
);
};
const generate = () => {
if (!playgroundDirectoryExist()) {
createPlaygroundDirectory();
}
cloneProjectSampleInPlayground();
installProjectSampleInPlayground();
};
const run = () => {
compileLibrary();
loadLibInPlayground();
console.log('Running playground, it might be take more than one minute for the first run...');
execSync('cd ./.playground/Lary-Scafold && yarn web', (error, stdout, stderr) => {
callback(stdout);
});
};
module.exports = {
generate,
run
};