NodeJs

目录

执行Shell


const { exec } = require('child_process')

function $exec(command) {
	return new Promise((resolve, reject)=>{
		exec(command, (err, line)=>{
			resolve(err || line)
		})
	})
}

(async ()=>{
	let result = await $exec('ls')
	console.log(result)
})()
const fs = require('fs');

fs.readdir('/', (err, files) => {
  //...
});

你可能感兴趣的:(node.js)