Skip to content

Commit

Permalink
Add description to package.json files
Browse files Browse the repository at this point in the history
  • Loading branch information
KSXGitHub committed Mar 28, 2021
1 parent 605a7a8 commit 30350de
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 18 deletions.
1 change: 1 addition & 0 deletions nodejs/wasm32-wasi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@sane-fmt/wasm32-wasi",
"version": "0.8.3",
"description": "Opinionated code formatter for TypeScript and JavaScript",
"private": false,
"homepage": "https://github.com/sane-fmt/sane-fmt",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions nodejs/x86_64-apple-darwin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@sane-fmt/x86_64-apple-darwin",
"version": "0.8.3",
"description": "Opinionated code formatter for TypeScript and JavaScript",
"private": false,
"homepage": "https://github.com/sane-fmt/sane-fmt",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions nodejs/x86_64-pc-windows-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@sane-fmt/x86_64-pc-windows-gnu",
"version": "0.8.3",
"description": "Opinionated code formatter for TypeScript and JavaScript",
"private": false,
"homepage": "https://github.com/sane-fmt/sane-fmt",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions nodejs/x86_64-pc-windows-msvc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@sane-fmt/x86_64-pc-windows-msvc",
"version": "0.8.3",
"description": "Opinionated code formatter for TypeScript and JavaScript",
"private": false,
"homepage": "https://github.com/sane-fmt/sane-fmt",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions nodejs/x86_64-unknown-linux-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@sane-fmt/x86_64-unknown-linux-gnu",
"version": "0.8.3",
"description": "Opinionated code formatter for TypeScript and JavaScript",
"private": false,
"homepage": "https://github.com/sane-fmt/sane-fmt",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions nodejs/x86_64-unknown-linux-musl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@sane-fmt/x86_64-unknown-linux-musl",
"version": "0.8.3",
"description": "Opinionated code formatter for TypeScript and JavaScript",
"private": false,
"homepage": "https://github.com/sane-fmt/sane-fmt",
"repository": {
Expand Down
60 changes: 42 additions & 18 deletions tests/package_manifests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,56 @@ pub use utils::*;
use cargo_toml::*;
use package_json::*;

macro_rules! test_version {
#[derive(Debug, PartialEq, Eq)]
struct PkgInfo {
version: String,
description: String,
}

impl PkgInfo {
fn load_cargo_manifest() -> Self {
let Package {
version,
description,
} = CargoManifest::load().package;
PkgInfo {
version,
description,
}
}

fn parse_node_manifest(text: &'static str) -> Self {
let NodeManifest {
version,
description,
} = NodeManifest::parse(text);
PkgInfo {
version,
description,
}
}
}

macro_rules! test_case {
($test_name:ident, $manifest_path:literal) => {
#[test]
fn $test_name() {
let native = CargoManifest::load();
let nodejs = NodeManifest::parse(include_str!($manifest_path));
assert_eq!(nodejs.version, native.package.version);
let native = PkgInfo::load_cargo_manifest();
let nodejs = PkgInfo::parse_node_manifest(include_str!($manifest_path));
assert_eq!(native, nodejs);
}
};
}

test_version!(wasi_version, "../nodejs/wasm32-wasi/package.json");
test_version!(apple_version, "../nodejs/x86_64-apple-darwin/package.json");
test_version!(
windows_gnu_version,
"../nodejs/x86_64-pc-windows-gnu/package.json"
);
test_version!(
windows_msvc_version,
test_case!(wasi, "../nodejs/wasm32-wasi/package.json");
test_case!(apple, "../nodejs/x86_64-apple-darwin/package.json");
test_case!(windows_gnu, "../nodejs/x86_64-pc-windows-gnu/package.json");
test_case!(
windows_msvc,
"../nodejs/x86_64-pc-windows-msvc/package.json"
);
test_version!(
linux_gnu_version,
"../nodejs/x86_64-unknown-linux-gnu/package.json"
);
test_version!(
linux_musl_version,
test_case!(linux_gnu, "../nodejs/x86_64-unknown-linux-gnu/package.json");
test_case!(
linux_musl,
"../nodejs/x86_64-unknown-linux-musl/package.json"
);
2 changes: 2 additions & 0 deletions tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ pub mod cargo_toml {
#[derive(Serialize, Deserialize)]
pub struct Package {
pub version: String,
pub description: String,
}
}

Expand All @@ -361,6 +362,7 @@ pub mod package_json {
#[derive(Serialize, Deserialize)]
pub struct NodeManifest {
pub version: String,
pub description: String,
}

impl NodeManifest {
Expand Down

0 comments on commit 30350de

Please sign in to comment.