path#parse JavaScript Examples
The following examples show how to use
path#parse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: setupTests-integration.js From hathor-wallet-headless with MIT License | 6 votes |
/**
* Gets the name of the test being executed from a Jasmine's global variable.
* @returns {string} Test name
*/
function getTestNameFromGlobalJasmineInstance() {
// eslint-disable-next-line no-undef
const { testPath } = jasmine;
const testFileName = parse(testPath).name;
return testFileName.indexOf('.') > -1
? testFileName.split('.')[0]
: testFileName;
}
Example #2
Source File: digital-ocean.js From medusa with MIT License | 6 votes |
upload(file) {
this.updateAwsConfig()
const parsedFilename = parse(file.originalname)
const fileKey = `${parsedFilename.name}-${Date.now()}${parsedFilename.ext}`
const s3 = new aws.S3()
const params = {
ACL: "public-read",
Bucket: this.bucket_,
Body: fs.createReadStream(file.path),
Key: fileKey,
}
return new Promise((resolve, reject) => {
s3.upload(params, (err, data) => {
if (err) {
reject(err)
return
}
if (this.spacesUrl_) {
resolve({ url: `${this.spacesUrl_}/${data.Key}` })
}
resolve({ url: data.Location })
})
})
}
Example #3
Source File: configHelpers.js From twin.macro with MIT License | 5 votes |
getRelativePath = ({ comparePath, state }) => {
const { filename } = state.file.opts
const pathName = parse(filename).dir
return relative(pathName, comparePath)
}