insomnia/plugins/insomnia-plugin-file/index.js

23 lines
403 B
JavaScript
Raw Normal View History

const fs = require('fs');
2018-06-25 17:42:50 +00:00
module.exports.templateTags = [
{
name: 'file',
displayName: 'File',
description: 'read contents from a file',
args: [
{
displayName: 'Choose File',
type: 'file',
},
2018-06-25 17:42:50 +00:00
],
run(context, path) {
if (!path) {
throw new Error('No file selected');
}
2018-06-25 17:42:50 +00:00
return fs.readFileSync(path, 'utf8');
},
},
2018-06-25 17:42:50 +00:00
];