Skip to content

Commit

Permalink
Merge pull request #7 from liuderchi/cross-platform-server-build
Browse files Browse the repository at this point in the history
Build Yaml Lang Server on Windows Platform
  • Loading branch information
liuderchi authored Oct 6, 2017
2 parents a8b5d20 + 30f8423 commit f9c5a9f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
42 changes: 42 additions & 0 deletions build-yaml-lang-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const fs= require('fs')
const path= require('path')
const childProcess = require('child_process')

const commands = [
{
name: 'Server Install',
run: () => childProcess.spawnSync(
'npm',
['install', '--prefix', 'node_modules/yaml-language-server'],
{ encoding: 'utf8' }
),
},
{
name: 'Server Compile',
run: () => childProcess.spawnSync(
'npm',
['run', 'compile', '--prefix', 'node_modules/yaml-language-server'],
{ encoding: 'utf8' }
),
},
]

commands.forEach(cmd => {
console.log(`Doing ${cmd.name}...`)
const { status } = cmd.run()
if (status !== 0) {
console.log(`${cmd.name} failed. Exit ${status}`)
process.exit(-1)
}
})

const serverPath = path.join(__dirname, 'node_modules/yaml-language-server/out/server/src/server.js')
console.log(`Checking built yaml lang server path: ${serverPath}`)

try {
fs.accessSync(serverPath)
} catch (e) {
console.log(`Yaml lang server ${serverPath} not found. Build failed.`)
process.exit(-1)
}
console.log('Server build success.')
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"main": "src/main.js",
"scripts": {
"install": "napa",
"postinstall": "npm run buildYamlServer",
"buildYamlServer": "npm install --prefix node_modules/yaml-language-server && npm run compile --prefix node_modules/yaml-language-server",
"lint": "eslint ./src",
"postinstall": "node build-yaml-lang-server.js",
"lint": "eslint ./",
"test": "npm run lint"
},
"repository": "https://github.com/liuderchi/ide-yaml.git",
Expand Down

0 comments on commit f9c5a9f

Please sign in to comment.