Skip to content

Commit 714c05f

Browse files
author
Cédric Belin
committed
Add a Visual Studio solution
1 parent 9dcb66c commit 714c05f

File tree

6 files changed

+102
-17
lines changed

6 files changed

+102
-17
lines changed

gulpfile.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import gulp from "gulp";
22
import {spawn} from "node:child_process";
3-
import {readdir, rm} from "node:fs/promises";
3+
import {glob, readdir, readFile, rm, writeFile} from "node:fs/promises";
44
import {join} from "node:path";
55
import pkg from "./package.json" with {type: "json"};
66

@@ -39,8 +39,25 @@ export async function test() {
3939
await run("node", "--enable-source-maps", "--test");
4040
}
4141

42+
/** Updates the version number in the sources. */
43+
export async function version() {
44+
for await (const file of glob("*/*.esproj"))
45+
await replaceInFile(file, /<Version>\d+(\.\d+){2}<\/Version>/, `<Version>${pkg.version}</Version>`);
46+
}
47+
4248
/** The default task. */
43-
export default gulp.series(clean, build);
49+
export default gulp.series(clean, version, build);
50+
51+
/**
52+
* Replaces the specified pattern in a given file.
53+
* @param {string} file The path of the file to be processed.
54+
* @param {RegExp} pattern The regular expression to find.
55+
* @param {string} replacement The replacement text.
56+
* @returns {Promise<void>} Resolves when the replacement has been completed.
57+
*/
58+
async function replaceInFile(file, pattern, replacement) {
59+
await writeFile(file, (await readFile(file, "utf8")).replace(pattern, replacement));
60+
}
4461

4562
/**
4663
* Spawns a new process using the specified command.

package-lock.json

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
"access": "public"
5656
},
5757
"scripts": {
58+
"build": "gulp build",
59+
"clean": "gulp clean",
5860
"test": "gulp test"
5961
}
6062
}

php_minifier.slnx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Solution>
2+
<Folder Name="/.config/">
3+
<File Path=".editorconfig" />
4+
<File Path=".gitattributes" />
5+
<File Path=".gitignore" />
6+
</Folder>
7+
<Folder Name="/bin/">
8+
<File Path="bin/php_minifier.js" />
9+
</Folder>
10+
<Folder Name="/build/">
11+
<File Path="gulpfile.js" />
12+
<File Path="run.ps1" />
13+
</Folder>
14+
<Folder Name="/doc/">
15+
<File Path="AUTHORS.txt" />
16+
<File Path="CHANGELOG.md" />
17+
<File Path="LICENSE.md" />
18+
<File Path="README.md" />
19+
</Folder>
20+
<Folder Name="/etc/">
21+
<File Path="etc/eslint.js" />
22+
<File Path="etc/typedoc.js" />
23+
</Folder>
24+
<Folder Name="/example/">
25+
<File Path="example/gulpfile.js" />
26+
</Folder>
27+
<Project Path="src/php_minifier.esproj">
28+
<Build />
29+
</Project>
30+
<Project Path="test/php_minifier.test.esproj">
31+
<Build />
32+
</Project>
33+
</Solution>

src/php_minifier.esproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.VisualStudio.JavaScript.Sdk/1.0.2191419">
2+
<PropertyGroup>
3+
<Company>Belin.io</Company>
4+
<Copyright>© Cédric Belin</Copyright>
5+
<Description>Minify PHP source code by removing comments and whitespace.</Description>
6+
<Product>PHP Minifier</Product>
7+
<Version>5.1.0</Version>
8+
</PropertyGroup>
9+
10+
<PropertyGroup>
11+
<PackageJsonDirectory>$(SolutionDir)</PackageJsonDirectory>
12+
<ShouldRunBuildScript>false</ShouldRunBuildScript>
13+
<ShouldRunNpmInstall>false</ShouldRunNpmInstall>
14+
</PropertyGroup>
15+
</Project>

test/php_minifier.test.esproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.VisualStudio.JavaScript.Sdk/1.0.2191419">
2+
<PropertyGroup>
3+
<Company>Belin.io</Company>
4+
<Copyright>© Cédric Belin</Copyright>
5+
<Product>PHP Minifier</Product>
6+
<Version>5.1.0</Version>
7+
</PropertyGroup>
8+
9+
<PropertyGroup>
10+
<PackageJsonDirectory>$(SolutionDir)</PackageJsonDirectory>
11+
<ShouldRunBuildScript>false</ShouldRunBuildScript>
12+
<ShouldRunNpmInstall>false</ShouldRunNpmInstall>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="../src/php_minifier.esproj" />
17+
</ItemGroup>
18+
</Project>

0 commit comments

Comments
 (0)