xy-server/node_modules/ts-node-dev/lib/get-compiled-path.js

14 lines
389 B
JavaScript
Raw Normal View History

2025-04-23 09:34:08 +08:00
var crypto = require('crypto')
var path = require('path')
var cwd = process.cwd()
module.exports = (code, fileName, compiledDir) => {
var hash = crypto
.createHash('sha256')
.update(fileName + code, 'utf8')
.digest('hex')
fileName = path.relative(cwd, fileName)
var hashed = fileName.replace(/[^\w]/g, '_') + '_' + hash + '.js'
return path.join(compiledDir, hashed)
}