-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
stamp.parsers
60 lines (57 loc) · 1.63 KB
/
stamp.parsers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// A joint effort from:
// - Breck Yunits https://github.com/breck7
// - Guillaume Papin https://github.com/Sarcasm
// Origin: https://github.com/breck7/scrollsdk/issues/120
stampFileParser
catchAllAtomType stringAtom
description Create a file.
javascript
build(parentDir) {
const fs = require("fs")
const path = require("path")
const fullPath = path.join(parentDir, this.getLine())
this.root.file.log(`Creating file ${fullPath}`)
fs.mkdirSync(path.dirname(fullPath), {recursive: true})
const content = this.subparticlesToString()
fs.writeFileSync(fullPath, content, "utf8")
const isExecutable = content.startsWith("#!")
if (isExecutable) fs.chmodSync(fullPath, "755")
}
stampFolderParser
catchAllAtomType stringAtom
description Create a folder.
inScope stampFolderParser
catchAllParser stampFileParser
pattern \/$
javascript
build(parentDir) {
const fs = require("fs")
const path = require("path")
const newPath = path.join(parentDir, this.getLine())
this.root.file.log(`Creating folder ${newPath}`)
fs.mkdirSync(newPath, {recursive: true})
this.forEach(particle => particle.build(newPath))
}
stampParser
description Expand project template to disk.
extends abstractScrollParser
inScope stampFolderParser
catchAllParser stampFileParser
example
stamp
.gitignore
*.html
readme.scroll
# Hello world
<script src="scripts/nested/hello.js"></script>
scripts/
nested/
hello.js
console.log("Hello world")
cruxFromId
atoms preBuildCommandAtom
javascript
build() {
const dir = this.root.file.folderPath
this.forEach(particle => particle.build(dir))
}