This repository has been archived by the owner on Sep 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathci.js
64 lines (51 loc) · 1.89 KB
/
ci.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
61
62
63
64
#!/usr/bin/env node
var path = require('path')
var saguiPath = path.join(__dirname, '..')
var version = require('../package.json').version
var tgzFile = path.join(saguiPath, `sagui-${version}.tgz`)
console.log('ENVIRONMENT', process.env)
function exec (command, cwd) {
// pass the parent´s stdio to the child process
// http://stackoverflow.com/a/31104898
require('child_process').execSync(command, { cwd: cwd, stdio: [0, 1, 2] })
}
function createTempFolder () {
return require('tmp').dirSync().name
}
if (process.env.TEST_TYPE === 'lint_and_test_unit') {
exec('npm run test:lint', saguiPath)
exec('npm run test:unit', saguiPath)
}
if (process.env.TEST_TYPE === 'integration_test') {
exec('npm run test:integration', saguiPath)
}
if (process.env.TEST_TYPE === 'test_create_project_npm') {
// # builds Sagui before installing
exec('npm run build', saguiPath)
exec('npm pack --ignore-scripts')
var npmProjectPath = createTempFolder()
// # Create a new project and install Sagui
exec('npm init -y .', npmProjectPath)
exec(`npm install --save-dev ${tgzFile}`, npmProjectPath)
// # Run some basic scripts
exec('npm test', npmProjectPath)
exec('npm run test:lint', npmProjectPath)
exec('npm run build', npmProjectPath)
exec('npm run dist', npmProjectPath)
exec('npm run format', npmProjectPath)
}
if (process.env.TEST_TYPE === 'test_create_project_yarn') {
// # builds Sagui before installing
exec('npm run build', saguiPath)
exec('npm pack --ignore-scripts')
var yarnProjectPath = createTempFolder()
// # Create a new project and install Sagui
exec('yarn init -y .', yarnProjectPath)
exec(`yarn add --dev ${tgzFile}`, yarnProjectPath)
// # Run some basic scripts
exec('yarn test', yarnProjectPath)
exec('yarn run test:lint', yarnProjectPath)
exec('yarn run build', yarnProjectPath)
exec('yarn run dist', yarnProjectPath)
exec('yarn run format', yarnProjectPath)
}