Skip to content

Commit

Permalink
make use of object shorthand and destructuring assignment
Browse files Browse the repository at this point in the history
[BREAKING] drop support for Node.js < 6
  • Loading branch information
shinnn committed Jul 26, 2018
1 parent 9ba597b commit a1d4136
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
'use strict';

const extname = require('path').extname;
const readFile = require('fs').readFile;
const {extname} = require('path');
const {readFile} = require('fs');

module.exports = function sassPackageImporter(path, prev, done) {
let resolvedPath;

try {
const resolvedPath = require.resolve(path);
const ext = extname(resolvedPath).slice(1).toLowerCase();
resolvedPath = require.resolve(path);
} catch (err) {
done({file: path});
return;
}

if (ext === 'js' || ext === 'json' || ext === 'mjs') {
done({file: path});
return;
}
const ext = extname(resolvedPath).slice(1).toLowerCase();

readFile(resolvedPath, 'utf8', (err, contents) => done(err || {
file: resolvedPath,
contents: contents // eslint-disable-line object-shorthand
}));
} catch (err) {
if (ext === 'js' || ext === 'json' || ext === 'mjs') {
done({file: path});
return;
}

readFile(resolvedPath, 'utf8', (err, contents) => done(err || {file: resolvedPath, contents}));
};

0 comments on commit a1d4136

Please sign in to comment.