编辑代码

function render(code) {
    
    return `
    "Print to console": {
		"prefix": "log",
		"body": [
			${code.join(',')}
		],
		"description": "Log output to console"
	}
    `
}

function parse(code) {
   return code.split('\n').map((val)=> val.replace('"', '\\"')).map((val) => val.replace(/\s{4}/g, '\\t')).map((val) => `"${val}"`);
}


console.log(render(parse(`
import { Component, Emit, Vue } from 'vue-property-decorator'

@Component({})
export default class Index extends Vue {

}
`)))