-
Notifications
You must be signed in to change notification settings - Fork 35
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 #324 from dotnet/dependabot/npm_and_yarn/multi-122…
…cf48755 Bump nanoid, gulp-mocha and mocha
- Loading branch information
Showing
5 changed files
with
633 additions
and
712 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 was deleted.
Oops, something went wrong.
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,103 @@ | ||
import { task, src, dest, series, parallel } from "gulp"; | ||
import mocha from "gulp-mocha"; | ||
import json2cson from "gulp-json2cson"; | ||
import yaml from "gulp-yaml"; | ||
import gulpTypescript from 'gulp-typescript'; | ||
const { createProject } = gulpTypescript; | ||
import { load } from "js-yaml"; | ||
import plist from 'plist'; | ||
const { build } = plist; | ||
import { readFileSync, existsSync, mkdirSync, writeFileSync } from "fs"; | ||
import { join } from "path"; | ||
import { exec } from "child_process"; | ||
|
||
const inputGrammar = "src/csharp.tmLanguage.yml"; | ||
const grammarsDirectory = "grammars/"; | ||
const jsOut = "out/"; | ||
|
||
|
||
function handleError(err) { | ||
console.log(err.toString()); | ||
process.exit(-1); | ||
} | ||
|
||
task('buildTmLanguage', done => { | ||
const text = readFileSync(inputGrammar); | ||
const jsonData = load(text); | ||
const plistData = build(jsonData); | ||
|
||
if (!existsSync(grammarsDirectory)) { | ||
mkdirSync(grammarsDirectory); | ||
} | ||
|
||
writeFileSync(join(grammarsDirectory, 'csharp.tmLanguage'), plistData); | ||
|
||
done(); | ||
}); | ||
|
||
task('buildVSCode', done => { | ||
const text = readFileSync(inputGrammar); | ||
const jsonData = load(text); | ||
|
||
if (!existsSync(grammarsDirectory)) { | ||
mkdirSync(grammarsDirectory); | ||
} | ||
|
||
// These fields aren't used. | ||
jsonData.uuid = undefined; | ||
jsonData.fileTypes = undefined; | ||
|
||
// Get the SHA of the last commit. | ||
exec("git rev-parse HEAD", (err, stdout, stderr) => { | ||
if (err) { | ||
handleErr(err); | ||
} | ||
|
||
const commitSha = stdout.trim(); | ||
|
||
// Add the additional properties used in the VSCode repo. | ||
const enhancedJson = { | ||
"information_for_contributors": [ | ||
"This file has been converted from https://github.com/dotnet/csharp-tmLanguage/blob/main/grammars/csharp.tmLanguage", | ||
"If you want to provide a fix or improvement, please create a pull request against the original repository.", | ||
"Once accepted there, we are happy to receive an update request." | ||
], | ||
"version": `https://github.com/dotnet/csharp-tmLanguage/commit/${commitSha}`, | ||
...jsonData | ||
} | ||
|
||
writeFileSync(join(grammarsDirectory, 'csharp.tmLanguage.json'), JSON.stringify(enhancedJson, null, '\t')); | ||
|
||
done(); | ||
}); | ||
}); | ||
|
||
task('buildAtom', () => { | ||
return src(inputGrammar) | ||
.pipe(yaml()) | ||
.pipe(json2cson()) | ||
.pipe(dest(grammarsDirectory)) | ||
.on("error", handleError); | ||
}); | ||
|
||
task('compile', () => { | ||
const tsProject = createProject("./tsconfig.json"); | ||
return tsProject.src() | ||
.pipe(tsProject()) | ||
.pipe(dest(jsOut)); | ||
}); | ||
|
||
task('test', series('compile', done => { | ||
const result = src(jsOut + "test/**/*.tests.js") | ||
.pipe(mocha()) | ||
.on("error", handleError); | ||
|
||
done(); | ||
|
||
return result; | ||
})); | ||
|
||
task('default', | ||
series( | ||
parallel('buildAtom', 'buildVSCode', 'buildTmLanguage'), | ||
'test')); |
Oops, something went wrong.