Skip to content

Commit

Permalink
Merge pull request #324 from dotnet/dependabot/npm_and_yarn/multi-122…
Browse files Browse the repository at this point in the history
…cf48755

Bump nanoid, gulp-mocha and mocha
  • Loading branch information
JoeRobich committed Jun 18, 2024
2 parents a27e9ea + 3359b38 commit 479bfb7
Show file tree
Hide file tree
Showing 5 changed files with 633 additions and 712 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Use Node.js 15.x
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: '15.x'
node-version: '18.x'
- run: npm ci # This will automatically build and run tests because the prepublish step is to run `gulp`
101 changes: 0 additions & 101 deletions gulpfile.js

This file was deleted.

103 changes: 103 additions & 0 deletions gulpfile.mjs
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'));
Loading

0 comments on commit 479bfb7

Please sign in to comment.