UNPKG

readsql

Version:

Converts SQL query file to string, allowing for use of SQL files in JavaScript

18 lines (15 loc) 405 B
var { readFileSync } = require('fs'); /** * @param {string} path Path to SQL query file */ function sql(path) { try { var query = readFileSync(path, 'utf-8'); return query.toString(); } catch (err) { err.toString().includes('no such file or directory') ? console.log(`No such file: '${path}'`) : console.log(err) } }; module.exports = sql;