fixed file path issue

This commit is contained in:
David Pichsenmeister 2020-06-29 18:15:54 -07:00
parent 7fd6fa686c
commit e14444d371
3 changed files with 20 additions and 17 deletions

View file

@ -35,12 +35,6 @@ WienerScript requires [Node.js and npm](https://nodejs.org/en/).
npm install -g wienerscript
```
or
```
yarn add global wienerscript
```
Usage:
```
@ -133,4 +127,4 @@ Examples can be found in the [examples](examples) directory.
This project is licensed under the MIT license, Copyright (c) 2020 David Pichsenmeister | [pichsenmeister.com](https://pichsenmeister.com). For more information see [LICENSE](LICENSE).
Made by [@pichsenmeister](https://twitter.com/pichsenmeister). Inspired by [ArnoldJS](https://github.com/pichsenmeister/ArnoldJS).
Made by [@pichsenmeister](https://twitter.com/pichsenmeister). Inspired by [ArnoldJS](https://github.com/theBrianCui/ArnoldJS).

View file

@ -7,12 +7,13 @@ const mkdirp = require('mkdirp')
const prettier = require('prettier')
// options is optional
const getFiles = () => {
return glob.sync("**/*.ws")
const getFiles = (currentPath) => {
const files = glob.sync(currentPath + "/**/*.ws")
return files.filter(file => file.indexOf('node_modules/') < 0)
}
const compile = (content) => {
const keywords = JSON.parse(fs.readFileSync('keywords.json', 'utf8'))
const keywords = JSON.parse(fs.readFileSync(path.join(__dirname, 'keywords.json'), 'utf8'))
for (const key in keywords) {
content = content.replace(new RegExp(key, "g"), keywords[key]);
}
@ -20,18 +21,26 @@ const compile = (content) => {
}
const run = () => {
const files = getFiles()
console.log('HAWIDERE')
const currentPath = process.cwd()
const files = getFiles(currentPath)
console.log('DO HOBN MA ' + files.length + ' GSCHICHTLN')
files.forEach(file => {
const content = fs.readFileSync(path.normalize(path.join(__dirname, file)), 'utf8')
const dir = path.join(__dirname, 'dist')
const content = fs.readFileSync(path.normalize(file), 'utf8')
const dir = path.join(currentPath, 'dist')
if (!fs.existsSync(dir)) fs.mkdirSync(dir)
const dirs = file.substring(0, file.lastIndexOf(path.sep))
mkdirp.sync(path.join(__dirname, 'dist', dirs))
const dirs = file.substring(0, file.lastIndexOf(path.sep)).replace(currentPath, '')
mkdirp.sync(path.join(currentPath, 'dist', dirs))
const filePath = path.join(__dirname, 'dist', file.replace('.ws', '.js'))
const filePath = path.join(currentPath, 'dist', file.replace(currentPath, '').replace('.ws', '.js'))
console.log('DRAH DI DEPATTA', file.replace(currentPath, '').replace(path.sep, '') + ' ==> ' + filePath.replace(currentPath, '').replace(path.sep, ''))
fs.writeFileSync(filePath, prettier.format(compile(content), { parser: 'babel' }), (error) => console.error(error))
})
console.log('PFIATI')
}
run()

View file

@ -1,6 +1,6 @@
{
"name": "wienerscript",
"version": "1.0.0",
"version": "1.0.1",
"description": "WienerScript adds syntactic WIENERISCH to JavaScript that makes it less forgiving, more emotional, and even painful to write, allowing you to do less with more code.",
"main": "./index.js",
"bin": {