mirror of
https://github.com/pichsenmeister/WienerScript.git
synced 2024-11-04 13:59:58 +00:00
fixed file path issue
This commit is contained in:
parent
7fd6fa686c
commit
e14444d371
3 changed files with 20 additions and 17 deletions
|
@ -35,12 +35,6 @@ WienerScript requires [Node.js and npm](https://nodejs.org/en/).
|
||||||
npm install -g wienerscript
|
npm install -g wienerscript
|
||||||
```
|
```
|
||||||
|
|
||||||
or
|
|
||||||
|
|
||||||
```
|
|
||||||
yarn add global wienerscript
|
|
||||||
```
|
|
||||||
|
|
||||||
Usage:
|
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).
|
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).
|
||||||
|
|
27
index.js
27
index.js
|
@ -7,12 +7,13 @@ const mkdirp = require('mkdirp')
|
||||||
const prettier = require('prettier')
|
const prettier = require('prettier')
|
||||||
|
|
||||||
// options is optional
|
// options is optional
|
||||||
const getFiles = () => {
|
const getFiles = (currentPath) => {
|
||||||
return glob.sync("**/*.ws")
|
const files = glob.sync(currentPath + "/**/*.ws")
|
||||||
|
return files.filter(file => file.indexOf('node_modules/') < 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
const compile = (content) => {
|
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) {
|
for (const key in keywords) {
|
||||||
content = content.replace(new RegExp(key, "g"), keywords[key]);
|
content = content.replace(new RegExp(key, "g"), keywords[key]);
|
||||||
}
|
}
|
||||||
|
@ -20,18 +21,26 @@ const compile = (content) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const run = () => {
|
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 => {
|
files.forEach(file => {
|
||||||
const content = fs.readFileSync(path.normalize(path.join(__dirname, file)), 'utf8')
|
const content = fs.readFileSync(path.normalize(file), 'utf8')
|
||||||
const dir = path.join(__dirname, 'dist')
|
const dir = path.join(currentPath, 'dist')
|
||||||
if (!fs.existsSync(dir)) fs.mkdirSync(dir)
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir)
|
||||||
|
|
||||||
const dirs = file.substring(0, file.lastIndexOf(path.sep))
|
const dirs = file.substring(0, file.lastIndexOf(path.sep)).replace(currentPath, '')
|
||||||
mkdirp.sync(path.join(__dirname, 'dist', dirs))
|
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))
|
fs.writeFileSync(filePath, prettier.format(compile(content), { parser: 'babel' }), (error) => console.error(error))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log('PFIATI')
|
||||||
}
|
}
|
||||||
|
|
||||||
run()
|
run()
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "wienerscript",
|
"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.",
|
"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",
|
"main": "./index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|
Loading…
Reference in a new issue