Sha256: d2d75bca9947c4c1a4e9cb6b495a42cbbf26a012c21a3f427bae0ccffe3c6a1f

Contents?: true

Size: 297 Bytes

Versions: 6

Compression:

Stored size: 297 Bytes

Contents

// Transform a path into a variable name
module.exports = function pathToIdentifier(path) {
  var escapedPath = path.replace(/[^a-zA-Z0-9_]/g, function (match) {
    if (match === '/') {
      return '$';
    } else {
      return '_';
    }
  });
  return '__commoner_module__' + escapedPath;
};

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sprockets-commoner-0.6.5 js/babel-plugin-sprockets-commoner-internal/path-to-identifier.js
sprockets-commoner-0.6.4 js/babel-plugin-sprockets-commoner-internal/path-to-identifier.js
sprockets-commoner-0.6.3 js/babel-plugin-sprockets-commoner-internal/path-to-identifier.js
sprockets-commoner-0.6.2 js/babel-plugin-sprockets-commoner-internal/path-to-identifier.js
sprockets-commoner-0.6.1 js/babel-plugin-sprockets-commoner-internal/path-to-identifier.js
sprockets-commoner-0.6.0 js/babel-plugin-sprockets-commoner-internal/path-to-identifier.js