-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from burl/master
added node module/segment that displays version from package.json in …
- Loading branch information
Showing
6 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
"os" | ||
) | ||
|
||
const pkgfile = "./package.json" | ||
|
||
type packageJSON struct { | ||
Version string `json:"version"` | ||
} | ||
|
||
func segmentNode(p *powerline) { | ||
stat, err := os.Stat(pkgfile) | ||
if err == nil && !stat.IsDir() { | ||
pkg := packageJSON{"!"} | ||
raw, err := ioutil.ReadFile(pkgfile) | ||
if err == nil { | ||
json.Unmarshal(raw, &pkg) | ||
} | ||
p.appendSegment("node-version", segment{ | ||
content: pkg.Version + " \u2B22", | ||
foreground: p.theme.NodeFg, | ||
background: p.theme.NodeBg, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,4 +102,7 @@ type Theme struct { | |
|
||
ShellVarFg uint8 | ||
ShellVarBg uint8 | ||
|
||
NodeFg uint8 | ||
NodeBg uint8 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters