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

21 lines
364 B
JavaScript
Raw Normal View History

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