init project
commit
b9c8e4a5a2
|
@ -0,0 +1,16 @@
|
|||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
.vscode
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear on external disk
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
package-lock.json
|
||||
|
||||
node_modules
|
||||
.vscode-test
|
||||
*.vsix
|
|
@ -0,0 +1,20 @@
|
|||
language: node_js
|
||||
|
||||
os:
|
||||
- osx
|
||||
|
||||
node_js:
|
||||
- node
|
||||
|
||||
install:
|
||||
- npm install
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- "node_modules"
|
||||
|
||||
script:
|
||||
- npm test
|
||||
|
||||
notifications:
|
||||
email: false
|
|
@ -0,0 +1,6 @@
|
|||
.vscode/**
|
||||
test/**
|
||||
.vscode-test/**
|
||||
package-lock.json
|
||||
.gitignore
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,20 @@
|
|||
# Build System
|
||||
> 🔥 类似sublime的Build System功能, 方便快速调试一些代码片断或想法。
|
||||
>> 目前只支持脚本语言的简单编译调试, 因为vscode原则上只是一个编辑器, 我并不希望把它变成一个IDE, 所以暂时并不打算支持那些需要复杂的编译环境及配置的语言。
|
||||
|
||||
[![Version](https://vsmarketplacebadge.apphb.com/version-short/yutent.build-system.svg)](https://marketplace.visualstudio.com/items?itemName=yutent.build-system)
|
||||
[![Rating](https://vsmarketplacebadge.apphb.com/rating-short/yutent.build-system.svg)](https://marketplace.visualstudio.com/items?itemName=yutent.build-system)
|
||||
[![Installs](https://vsmarketplacebadge.apphb.com/installs/yutent.build-system.svg)](https://marketplace.visualstudio.com/items?itemName=yutent.build-system)
|
||||
[![Build Status](https://travis-ci.org/yutent/build-system.svg?branch=master)](https://travis-ci.org/yutent/build-system)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 兼容性
|
||||
> 理论上, 兼容Linux/MacOS/Windows, 不过我只在Linux/MacOS下测试过, 用Windows的童鞋请自行测试,有什么问题, 可以提issue。
|
||||
|
||||
## 安装
|
||||
> 直接在商店搜索安装即可。
|
||||
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
/**
|
||||
* 编译系统
|
||||
*
|
||||
* @author yutent<yutent@doui.cc>
|
||||
* @date 2018/12/20 11:37:54
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const vsc = require('vscode')
|
||||
const exec = require('child_process').exec
|
||||
const path = require('path')
|
||||
const os = require('os')
|
||||
const kill = require('tree-kill')
|
||||
|
||||
const log = console.log
|
||||
const std = vsc.window.createOutputChannel('build-system')
|
||||
std.out = function(msg) {
|
||||
std.appendLine(msg)
|
||||
}
|
||||
|
||||
const EXTS = {
|
||||
'.bat': 'cmd /c',
|
||||
'.dart': 'dart',
|
||||
'.go': 'go run',
|
||||
'.js': 'node',
|
||||
'.py': 'python -u',
|
||||
'.sh': 'bash',
|
||||
'.swift': 'swift',
|
||||
'.ts': 'ts-note'
|
||||
}
|
||||
|
||||
const BuildSystem = {
|
||||
build() {
|
||||
let editor = vsc.window.activeTextEditor
|
||||
|
||||
if (this.__RUNNING__) {
|
||||
return
|
||||
}
|
||||
|
||||
if (editor) {
|
||||
this.__DOC__ = editor.document
|
||||
this.__CWD__ = path.dirname(this.__DOC__.fileName)
|
||||
|
||||
if (this.__DOC__.languageId === 'Log') {
|
||||
return
|
||||
}
|
||||
|
||||
// 先保存
|
||||
if (this.__OPTION__.saveBeforeBuild) {
|
||||
vsc.workspace
|
||||
.saveAll()
|
||||
.then(_ => {
|
||||
if (this.__DOC__.isUntitled) {
|
||||
if (!this.__DOC__.isDirty) {
|
||||
return Promise.reject('空文件无法直接执行...')
|
||||
}
|
||||
return this.__DOC__.save()
|
||||
}
|
||||
return true
|
||||
})
|
||||
.then(saved => {
|
||||
log(this.__DOC__, saved)
|
||||
if (saved) {
|
||||
this.__start__()
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
vsc.window.showInformationMessage('空文件无法直接执行...')
|
||||
})
|
||||
} else {
|
||||
this.__start__()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
stop() {
|
||||
if (this.__PROGRESS__) {
|
||||
kill(this.__PROGRESS__.pid)
|
||||
}
|
||||
this.__RUNNING__ = false
|
||||
// todo...
|
||||
},
|
||||
|
||||
// 初始化 配置
|
||||
__init__(opt) {
|
||||
this.__OPTION__ = opt
|
||||
},
|
||||
|
||||
__start__() {
|
||||
this.__parseCmd__()
|
||||
|
||||
log(this.__CMD__)
|
||||
if (!this.__CMD__) {
|
||||
return
|
||||
}
|
||||
|
||||
this.__RUNNING__ = true
|
||||
if (this.__OPTION__.runInTerminal) {
|
||||
this.__runInTerminal__()
|
||||
} else {
|
||||
this.__output__()
|
||||
}
|
||||
},
|
||||
|
||||
__parseCmd__() {
|
||||
let firstLine = this.__DOC__.lineAt(0).text
|
||||
let ext = path.extname(this.__DOC__.fileName)
|
||||
let lang = EXTS[ext]
|
||||
if (firstLine.startsWith('#!')) {
|
||||
lang = firstLine.slice(2)
|
||||
}
|
||||
if (!lang) {
|
||||
this.__CMD__ = null
|
||||
if (this.__OPTION__.runInTerminal) {
|
||||
if (this.__TERMINAL__) {
|
||||
vsc.commands.executeCommand('workbench.action.terminal.clear')
|
||||
}
|
||||
} else {
|
||||
std.clear()
|
||||
}
|
||||
return vsc.window.showInformationMessage('不支持的语言...')
|
||||
}
|
||||
this.__CMD__ = `${lang} "${this.__DOC__.fileName}"`
|
||||
},
|
||||
|
||||
// 在终端内运行
|
||||
__runInTerminal__() {
|
||||
let hasTerminal = vsc.window.terminals.some(it => it.name === 'BuildSystem')
|
||||
|
||||
if (hasTerminal) {
|
||||
vsc.window.terminals.forEach(it => {
|
||||
if (it.name === 'BuildSystem') {
|
||||
this.__TERMINAL__ = it
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.__TERMINAL__ = vsc.window.createTerminal('BuildSystem')
|
||||
}
|
||||
this.__TERMINAL__.show()
|
||||
|
||||
if (hasTerminal) {
|
||||
vsc.commands.executeCommand('workbench.action.terminal.clear').then(_ => {
|
||||
this.__TERMINAL__.sendText(this.__CMD__)
|
||||
this.__RUNNING__ = false
|
||||
})
|
||||
} else {
|
||||
this.__TERMINAL__.sendText(this.__CMD__)
|
||||
this.__RUNNING__ = false
|
||||
}
|
||||
},
|
||||
|
||||
// 直接输出
|
||||
__output__() {
|
||||
// 运行前先清除之前的输出
|
||||
std.clear()
|
||||
|
||||
std.show(true)
|
||||
|
||||
let t1 = Date.now()
|
||||
|
||||
this.__PROGRESS__ = exec(this.__CMD__, { cwd: this.__CWD__ })
|
||||
|
||||
// 运行输出
|
||||
this.__PROGRESS__.stdout.on('data', _ => {
|
||||
std.append(_)
|
||||
})
|
||||
|
||||
// 异常输出
|
||||
this.__PROGRESS__.stderr.on('data', _ => {
|
||||
std.append(_)
|
||||
})
|
||||
|
||||
// 结束
|
||||
this.__PROGRESS__.on('close', _ => {
|
||||
let t2 = Date.now()
|
||||
let time = (t2 - t1) / 1000
|
||||
std.out('')
|
||||
std.out('[Finished in ' + time + ' seconds]')
|
||||
this.__PROGRESS__ = null
|
||||
this.__RUNNING__ = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BuildSystem
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* build system
|
||||
* @author yutent<yutent@doui.cc>
|
||||
* @date 2018/12/20 10:46:07
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const vsc = require('vscode')
|
||||
|
||||
const BuildSystem = require('./build_system')
|
||||
|
||||
function activate(ctx) {
|
||||
let conf = vsc.workspace.getConfiguration('BuildSystem')
|
||||
|
||||
BuildSystem.__init__(conf)
|
||||
|
||||
vsc.window.onDidCloseTerminal(() => {
|
||||
// BuildSystem.onDidCloseTerminal()
|
||||
})
|
||||
|
||||
const build = vsc.commands.registerCommand('BuildSystem.build', _ => {
|
||||
BuildSystem.build()
|
||||
})
|
||||
|
||||
const stop = vsc.commands.registerCommand('BuildSystem.stop', _ => {
|
||||
BuildSystem.stop()
|
||||
})
|
||||
|
||||
ctx.subscriptions.push(build)
|
||||
ctx.subscriptions.push(stop)
|
||||
}
|
||||
|
||||
function deactivate() {}
|
||||
|
||||
exports.activate = activate
|
||||
exports.deactivate = deactivate
|
|
@ -0,0 +1,94 @@
|
|||
{
|
||||
"name": "build-system",
|
||||
"displayName": "sublime build system",
|
||||
"description": "🔥 类似sublime的Build System功能, 方便快速调试一些代码片断或想法。",
|
||||
"version": "0.9.0",
|
||||
"publisher": "yutent",
|
||||
"author": "Yutent [@yutent]",
|
||||
"icon": "logo.png",
|
||||
"engines": {
|
||||
"vscode": "^1.28.0"
|
||||
},
|
||||
"categories": ["Programming Languages", "Other"],
|
||||
"activationEvents": ["*"],
|
||||
"main": "./index",
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"command": "BuildSystem.build",
|
||||
"title": "Build and run..."
|
||||
},
|
||||
{
|
||||
"command": "BuildSystem.stop",
|
||||
"title": "Stop run..."
|
||||
}
|
||||
],
|
||||
"keybindings": [
|
||||
{
|
||||
"command": "BuildSystem.build",
|
||||
"key": "cmd+alt+b"
|
||||
},
|
||||
{
|
||||
"command": "BuildSystem.stop",
|
||||
"key": "cmd+alt+c"
|
||||
}
|
||||
],
|
||||
"menus": {
|
||||
"editor/context": [
|
||||
{
|
||||
"when": "!inOutput",
|
||||
"command": "BuildSystem.build",
|
||||
"title": "Build and run this file"
|
||||
},
|
||||
{
|
||||
"when": "inOutput",
|
||||
"command": "BuildSystem.stop",
|
||||
"group": "Stop run this file"
|
||||
}
|
||||
]
|
||||
},
|
||||
"configuration": {
|
||||
"type": "object",
|
||||
"title": "Sublime Build System 配置",
|
||||
"properties": {
|
||||
"BuildSystem.saveBeforeBuild": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "编译之前先保存文件"
|
||||
},
|
||||
"BuildSystem.runInTerminal": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "是否使用终端来运行编译结果"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/yutent/build-system.git"
|
||||
},
|
||||
"keywords": [
|
||||
"run code",
|
||||
"sublime",
|
||||
"build",
|
||||
"system",
|
||||
"sublime build system",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"nodejs",
|
||||
"python",
|
||||
"yutent"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "node ./node_modules/vscode/bin/test"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"vscode": "^1.1.21"
|
||||
},
|
||||
"dependencies": {
|
||||
"iofs": "^1.1.0",
|
||||
"tree-kill": "^1.2.1"
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
void main() {
|
||||
print('hello dart');
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
console.log('hello js blabla')
|
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
|
||||
|
||||
echo 'hello php';
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @author yutent<yutent@doui.cc>
|
||||
# @date 2018/12/20 16:24:15
|
||||
|
||||
|
||||
print('hello python')
|
|
@ -0,0 +1,9 @@
|
|||
const testRunner = require('vscode/lib/testrunner')
|
||||
|
||||
testRunner.configure({
|
||||
ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
|
||||
useColors: true, // colored output from test results
|
||||
timeout: 10000
|
||||
})
|
||||
|
||||
module.exports = testRunner
|
Loading…
Reference in New Issue