Skip to content

Commit 479bfb7

Browse files
authored
Merge pull request #324 from dotnet/dependabot/npm_and_yarn/multi-122cf48755
Bump nanoid, gulp-mocha and mocha
2 parents a27e9ea + 3359b38 commit 479bfb7

File tree

5 files changed

+633
-712
lines changed

5 files changed

+633
-712
lines changed

.github/workflows/node.js.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616

1717
steps:
1818
- uses: actions/checkout@v2
19-
- name: Use Node.js 15.x
19+
- name: Use Node.js 18.x
2020
uses: actions/setup-node@v1
2121
with:
22-
node-version: '15.x'
22+
node-version: '18.x'
2323
- run: npm ci # This will automatically build and run tests because the prepublish step is to run `gulp`

gulpfile.js

Lines changed: 0 additions & 101 deletions
This file was deleted.

gulpfile.mjs

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import { task, src, dest, series, parallel } from "gulp";
2+
import mocha from "gulp-mocha";
3+
import json2cson from "gulp-json2cson";
4+
import yaml from "gulp-yaml";
5+
import gulpTypescript from 'gulp-typescript';
6+
const { createProject } = gulpTypescript;
7+
import { load } from "js-yaml";
8+
import plist from 'plist';
9+
const { build } = plist;
10+
import { readFileSync, existsSync, mkdirSync, writeFileSync } from "fs";
11+
import { join } from "path";
12+
import { exec } from "child_process";
13+
14+
const inputGrammar = "src/csharp.tmLanguage.yml";
15+
const grammarsDirectory = "grammars/";
16+
const jsOut = "out/";
17+
18+
19+
function handleError(err) {
20+
console.log(err.toString());
21+
process.exit(-1);
22+
}
23+
24+
task('buildTmLanguage', done => {
25+
const text = readFileSync(inputGrammar);
26+
const jsonData = load(text);
27+
const plistData = build(jsonData);
28+
29+
if (!existsSync(grammarsDirectory)) {
30+
mkdirSync(grammarsDirectory);
31+
}
32+
33+
writeFileSync(join(grammarsDirectory, 'csharp.tmLanguage'), plistData);
34+
35+
done();
36+
});
37+
38+
task('buildVSCode', done => {
39+
const text = readFileSync(inputGrammar);
40+
const jsonData = load(text);
41+
42+
if (!existsSync(grammarsDirectory)) {
43+
mkdirSync(grammarsDirectory);
44+
}
45+
46+
// These fields aren't used.
47+
jsonData.uuid = undefined;
48+
jsonData.fileTypes = undefined;
49+
50+
// Get the SHA of the last commit.
51+
exec("git rev-parse HEAD", (err, stdout, stderr) => {
52+
if (err) {
53+
handleErr(err);
54+
}
55+
56+
const commitSha = stdout.trim();
57+
58+
// Add the additional properties used in the VSCode repo.
59+
const enhancedJson = {
60+
"information_for_contributors": [
61+
"This file has been converted from https://github.com/dotnet/csharp-tmLanguage/blob/main/grammars/csharp.tmLanguage",
62+
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
63+
"Once accepted there, we are happy to receive an update request."
64+
],
65+
"version": `https://github.com/dotnet/csharp-tmLanguage/commit/${commitSha}`,
66+
...jsonData
67+
}
68+
69+
writeFileSync(join(grammarsDirectory, 'csharp.tmLanguage.json'), JSON.stringify(enhancedJson, null, '\t'));
70+
71+
done();
72+
});
73+
});
74+
75+
task('buildAtom', () => {
76+
return src(inputGrammar)
77+
.pipe(yaml())
78+
.pipe(json2cson())
79+
.pipe(dest(grammarsDirectory))
80+
.on("error", handleError);
81+
});
82+
83+
task('compile', () => {
84+
const tsProject = createProject("./tsconfig.json");
85+
return tsProject.src()
86+
.pipe(tsProject())
87+
.pipe(dest(jsOut));
88+
});
89+
90+
task('test', series('compile', done => {
91+
const result = src(jsOut + "test/**/*.tests.js")
92+
.pipe(mocha())
93+
.on("error", handleError);
94+
95+
done();
96+
97+
return result;
98+
}));
99+
100+
task('default',
101+
series(
102+
parallel('buildAtom', 'buildVSCode', 'buildTmLanguage'),
103+
'test'));

0 commit comments

Comments
 (0)