Ejemplo n.º 1
0
        /// <summary>
        /// Creates an NpmException with properties from the error output
        /// </summary>
        /// <param name="output">The error stream output from npm</param>
        /// <returns>a new NpmException</returns>
        public NpmException ExceptionFromError(string output)
        {
            if (output == null)
            {
                return null;
            }

            NpmException exception = new NpmException(NpmReportedError);
            string[] errorLines = output.Split('\n');

            foreach (string line in errorLines)
            {
                if (line.StartsWith(NpmErrorLineStart, StringComparison.Ordinal))
                {
                    string errorText = line.Substring(NpmErrorLineStart.Length);
                    exception.SetNpmValue(errorText);
                }
            }

            return exception;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Expected exception for install error
        /// </summary>
        /// <returns>Predictable exception for install error</returns>
        public static NpmException ErrorInstallExpected()
        {
            NpmException except = new NpmException("Failed: npm reported an error.");
            except.NpmSystem = "Windows_NT 6.1.7601";
            except.NpmCommand = "\"C:\\Program Files (x86)\\nodejs\\node.exe\" \"C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js\" \"install\" \"fffggghhh\"";
            except.NpmCwd = "C:\\src";
            except.NpmNodeVersion = "v0.6.13";
            except.NpmNpmVersion = "1.1.9";
            except.NpmCode = "E404";
            except.NpmMessage = "404 Not Found: bogusmod";
            except.NpmErrno = "{}";
            except.NpmVerbose = "'bogusmod' is not in the npm registry.\n" +
                                "You should bug the author to publish it\n" +
                                "\n" +
                                "Note that you can also install from a\n" +
                                "tarball, folder, or http url, or git url.\n" +
                                "\n" +
                                "\n" +
                                "Additional logging details can be found in:\n" +
                                "    C:\\src\\npm-debug.log\n";

            return except;
        }