安装
npm install site-ftp --save-dev
NPM地址:https://www.npmjs.com/package/site-ftp
create a file ftp.js
const { SiteFtp } = require('site-ftp');
SiteFtp.connect({
"host": "localhost",
"port": 21,
"username": "anonymous",
"password": "anonymous@",
"type": "ftp",
"from": ["dist/**"],
"to": "/public_html/",
"rm": true
});
run node
node ftp.js
console √ Finished!
i {"host":"","port":21,"username":"","password":"","type":"ftp","from":["dist/**","src"],"to":"/public_html/","rm":true}
i Connecting...
i Deleting the ftp folder`/public_html/`
√ Successfully deleted the ftp folder`/public_html/`
i Uploading...
√ Finished!