about summary refs log tree commit diff
path: root/pkgs/by-name/ug/uglify-js/package.nix
blob: 4056c78af31f08302fe88e80e3fb95ce0a97dce2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{
  lib,
  buildNpmPackage,
  fetchFromGitHub,
  testers,
  runCommand,
  writeText,
  uglify-js,
}:

buildNpmPackage rec {
  pname = "uglify-js";
  version = "3.18.0";

  src = fetchFromGitHub {
    owner = "mishoo";
    repo = "UglifyJS";
    rev = "v${version}";
    hash = "sha256-m+OEcvWEk4RX0C4re9TFZpkcBvSwl7qfIM+56t100ws=";
  };

  npmDepsHash = "sha256-iLWmNifHpVvFSFXkfItVpGlh6za9T9wSr1Af4CQQSGM=";

  postPatch = ''
    cp ${./package-lock.json} package-lock.json
  '';

  dontNpmBuild = true;

  passthru = {
    updateScript = ./update.sh;
    tests = {
      version = testers.testVersion { package = uglify-js; };

      simple = testers.testEqualContents {
        assertion = "uglify-js minifies a basic js file";
        expected = writeText "expected" ''
          console.log(1);
        '';
        actual =
          runCommand "actual"
            {
              nativeBuildInputs = [ uglify-js ];
              base = writeText "base" ''
                console . log  ( ( 1 ) ) ;
              '';
            }
            ''
              uglifyjs $base > $out
            '';
      };
    };
  };

  meta = {
    homepage = "https://github.com/mishoo/UglifyJS";
    description = "JavaScript parser / mangler / compressor / beautifier toolkit";
    mainProgram = "uglifyjs";
    license = lib.licenses.bsd2;
    maintainers = with lib.maintainers; [ lelgenio ];
  };
}