Skip to content

Commit 197b835

Browse files
Merge pull request #79 from omniomi/tools-and-docs
Tools and docs
2 parents 1642155 + 8d9889b commit 197b835

File tree

5 files changed

+142
-0
lines changed

5 files changed

+142
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
syntaxes/
2+
tools/node_modules/
3+
tools/package-lock.json

ISSUE_TEMPLATE.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!--
2+
BEFORE SUBMITTING A NEW ISSUE...
3+
4+
Please try a different theme to make sure the problem
5+
is not with the theme and is actually with the syntax.
6+
7+
If you are not reporting a bug please remove this template
8+
and describe the issue in your own words.
9+
-->
10+
11+
### Environment
12+
13+
- Editor and Version (VS Code, Atom, Sublime):
14+
- Your primary theme:
15+
16+
### Issue Description
17+
18+
<!-- Describe the issue in detail -->
19+
20+
#### Screenshots
21+
22+
<!-- If possible include screenshots of the issue -->
23+
24+
### Expected Behavior
25+
26+
<!-- How would you expect it to behave -->
27+
28+
### Code Samples
29+
30+
<!--
31+
Include any code sippets that can be used to reproduce the
32+
described behavior.
33+
-->
34+
35+
```PowerShell
36+
37+
38+
```

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,36 @@ both VS Code and Sublime Text. There are a number of existing issues with the g
2222
that we need to track down and fix. Please see [issue #1](https://github.com/PowerShell/EditorSyntax/issues/1)
2323
for more details.
2424

25+
## Build and Import (VS Code)
26+
27+
### Prerequisites
28+
29+
- Node.JS, >= 8.9.1
30+
31+
### Build
32+
33+
1. Navigate via command line to the `./tools/` directory and install dependencies:
34+
35+
```
36+
npm install
37+
```
38+
39+
2. Run the `build-grammar` script to generate the json file.
40+
41+
```
42+
npm run build-grammar
43+
```
44+
45+
3. The .json file will be generated in `./syntaxes/` at the root of the project. You will need to copy it in to VS Code manually.
46+
47+
1. Locate the VS Code installation directory and navigate to to `resources/app/extensions/powershell/syntaxes`
48+
49+
2. Rename `powershell.tmLanguage.json` to `powershell.tmLanguage.json_default`
50+
51+
3. Copy `powershell.tmLanguage.json` from `./syntaxes/` within the project folder to where you just renamed the file under VS Code's path.
52+
53+
4. If VS Code is already running you will need to run "Reload Window" from the command pallete.
54+
2555
## Contributing
2656
2757
We would love to have community contributions to this project to make PowerShell syntax

tools/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "editorsyntax",
3+
"license" : "MIT",
4+
"description": "PowerShell language syntax",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/PowerShell/EditorSyntax.git"
8+
},
9+
"version": "1.0.0",
10+
"dependencies": {
11+
"fast-plist": "0.1.2"
12+
},
13+
"scripts": {
14+
"build-grammar": "node ./scripts/build-grammar.js ../PowerShellSyntax.tmLanguage ../syntaxes/powershell.tmLanguage.json"
15+
}
16+
}

tools/scripts/build-grammar.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Licensed under the MIT License. See License.txt in the project root for license information.
3+
*
4+
* Modified for PowerShell\EditorSyntax from Microsoft\vscode (update-grammar.js)
5+
* This script generates the JSON file using the same tools as vscode's build.
6+
*--------------------------------------------------------------------------------------------*/
7+
8+
'use strict';
9+
10+
var path = require('path');
11+
var fs = require('fs');
12+
var plist = require('fast-plist');
13+
14+
exports.update = function (tmlPath, dest) {
15+
console.log('... Reading source file.');
16+
var content = fs.readFileSync(tmlPath).toString();
17+
18+
console.log('... Parsing content.');
19+
var grammar;
20+
grammar = plist.parse(content);
21+
22+
console.log('... Building contents.');
23+
let result = {
24+
information_for_contributors: [
25+
'This file has been converted from source and may not be in line with the official build.',
26+
'The current master branch for this syntax can be found here: https://github.com/PowerShell/EditorSyntax',
27+
'If you want to provide a fix or improvement, please create a pull request against the original repository.'
28+
]
29+
};
30+
31+
result.version = require('child_process')
32+
.execSync('git rev-parse HEAD')
33+
.toString().trim()
34+
35+
let keys = ['name', 'scopeName', 'comment', 'injections', 'patterns', 'repository'];
36+
for (let key of keys) {
37+
if (grammar.hasOwnProperty(key)) {
38+
result[key] = grammar[key];
39+
}
40+
}
41+
42+
var dirname = path.dirname(dest);
43+
if (!fs.existsSync(dirname)) {
44+
console.log('... Creating directory: ' + dirname);
45+
fs.mkdirSync(dirname);
46+
}
47+
48+
fs.writeFileSync(dest, JSON.stringify(result, null, '\t'));
49+
console.log('[Finished] File written to: ' + dest);
50+
};
51+
52+
if (path.basename(process.argv[1]) === 'build-grammar.js') {
53+
console.log('[Starting] Converting ' + process.argv[2] + ' to json.');
54+
exports.update(process.argv[2], process.argv[3]);
55+
}

0 commit comments

Comments
 (0)