paths.macro
Advanced tools
Comparing version 2.0.2 to 3.0.0
22
macro.js
@@ -5,3 +5,3 @@ const path = require('path'); | ||
const findRoot = require('find-root'); | ||
const { createMacro } = require('babel-macros'); | ||
const { createMacro } = require('babel-plugin-macros'); | ||
const { toUnix } = require('upath'); | ||
@@ -13,10 +13,14 @@ | ||
const _file = path.basename(_fileAbsolute); | ||
const _extention = path.extname(_fileAbsolute); | ||
const _filename = _file.replace(_extention, ''); | ||
const _extension = path.extname(_fileAbsolute); | ||
const _filename = _file.replace(_extension, ''); | ||
const _npmRoot = toUnix(findRootAttempt(_osDependentAbsolute)); | ||
const _gitRoot = toUnix(findRootAttempt(_osDependentAbsolute, (dir) => fs.existsSync(path.resolve(dir, '.git')))); | ||
const _gitRoot = toUnix( | ||
findRootAttempt(_osDependentAbsolute, dir => | ||
fs.existsSync(path.resolve(dir, '.git')), | ||
), | ||
); | ||
const _wd = toUnix(process.cwd()); | ||
const _baseAbsolute = _fileAbsolute.replace(_file, ''); | ||
@@ -31,3 +35,3 @@ const _base = _baseAbsolute.replace(_npmRoot, ''); | ||
file: _file, | ||
extention: _extention, | ||
extension: _extension, | ||
filename: _filename, | ||
@@ -58,5 +62,5 @@ baseAbsolute: _baseAbsolute, | ||
}); | ||
}) | ||
}); | ||
}; | ||
module.exports = createMacro(macro); |
{ | ||
"name": "paths.macro", | ||
"version": "2.0.2", | ||
"version": "3.0.0", | ||
"description": "Babel plugin that returns an object containing paths like __dirname and __filename as static values", | ||
@@ -30,11 +30,10 @@ "keywords": [ | ||
"dependencies": { | ||
"babel-macros": "^1.2.0", | ||
"babel-plugin-macros": "^2.0.0", | ||
"babel-plugin-macros": "^2.8.0", | ||
"find-root": "^1.1.0", | ||
"upath": "^1.0.2" | ||
"upath": "^1.2.0" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "^6.26.0", | ||
"jest": "^22.1.4" | ||
"@babel/core": "^7.10.2", | ||
"jest": "^26.0.1" | ||
} | ||
} |
@@ -14,3 +14,3 @@ # Babel paths.macro | ||
file | `input.js` | ||
extention | `.js` | ||
extension | `.js` | ||
filename | `input` | ||
@@ -27,3 +27,3 @@ baseAbsolute | `/Users/you/project/src/` | ||
```js | ||
import base, { filename } from 'babel-plugin-module-paths/paths.macro'; | ||
import base, { filename } from 'paths.macro'; | ||
@@ -36,3 +36,3 @@ console.log(base, filename); | ||
return [filename, base]; | ||
}; | ||
} | ||
``` | ||
@@ -49,3 +49,3 @@ | ||
return ["input", "/src/"]; | ||
}; | ||
} | ||
``` | ||
@@ -58,3 +58,3 @@ | ||
```sh | ||
yarn add babel-plugin-module-paths | ||
yarn add paths.macro | ||
``` | ||
@@ -61,0 +61,0 @@ |
@@ -9,2 +9,2 @@ import base, { filename } from '../macro'; | ||
return [filename, base]; | ||
}; | ||
} |
@@ -1,2 +0,2 @@ | ||
const babel = require('babel-core'); | ||
const babel = require('@babel/core'); | ||
@@ -3,0 +3,0 @@ const options = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
68
4324
7
- Removedbabel-macros@^1.2.0
- Removedargparse@1.0.10(transitive)
- Removedbabel-macros@1.2.0(transitive)
- Removedcosmiconfig@3.1.0(transitive)
- Removedesprima@4.0.1(transitive)
- Removedis-directory@0.3.1(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedparse-json@3.0.0(transitive)
- Removedrequire-from-string@2.0.2(transitive)
- Removedsprintf-js@1.0.3(transitive)
Updatedbabel-plugin-macros@^2.8.0
Updatedupath@^1.2.0